/[gentoo-projects]/pax-utils/scanelf.c
Gentoo

Diff of /pax-utils/scanelf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.16 Revision 1.17
1/* 1/*
2 * Copyright 2003 Ned Ludd <solar@gentoo.org> 2 * Copyright 2003 Ned Ludd <solar@gentoo.org>
3 * Copyright 1999-2005 Gentoo Foundation 3 * Copyright 1999-2005 Gentoo Foundation
4 * Distributed under the terms of the GNU General Public License v2 4 * Distributed under the terms of the GNU General Public License v2
5 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.16 2005/04/01 20:44:11 solar Exp $ 5 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.17 2005/04/02 00:11:01 vapier Exp $
6 * 6 *
7 ******************************************************************** 7 ********************************************************************
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the 10 * published by the Free Software Foundation; either version 2 of the
31#include <dirent.h> 31#include <dirent.h>
32#include <getopt.h> 32#include <getopt.h>
33 33
34#include "paxelf.h" 34#include "paxelf.h"
35 35
36static const char *rcsid = "$Id: scanelf.c,v 1.16 2005/04/01 20:44:11 solar Exp $"; 36static const char *rcsid = "$Id: scanelf.c,v 1.17 2005/04/02 00:11:01 vapier Exp $";
37 37
38 38
39/* helper functions for showing errors */ 39/* helper functions for showing errors */
40#define argv0 "scanelf\0" /*((*argv != NULL) ? argv[0] : __FILE__ "\b\b")*/ 40#define argv0 "scanelf\0" /*((*argv != NULL) ? argv[0] : __FILE__ "\b\b")*/
41#define warn(fmt, args...) \ 41#define warn(fmt, args...) \
234} 234}
235 235
236/* scan /etc/ld.so.conf for paths */ 236/* scan /etc/ld.so.conf for paths */
237static void scanelf_ldpath() 237static void scanelf_ldpath()
238{ 238{
239 char scan_l, scan_ul, scan_ull;
239 char *path, *p; 240 char *path, *p;
240 FILE *fp; 241 FILE *fp;
241 242
242 if ((fp = fopen("/etc/ld.so.conf", "r")) == NULL) 243 if ((fp = fopen("/etc/ld.so.conf", "r")) == NULL)
243 err("Unable to open ld.so.conf: %s", strerror(errno)); 244 err("Unable to open ld.so.conf: %s", strerror(errno));
245
246 scan_l = scan_ul = scan_ull = 0;
244 247
245 path = malloc(_POSIX_PATH_MAX); 248 path = malloc(_POSIX_PATH_MAX);
246 while ((fgets(path, _POSIX_PATH_MAX, fp)) != NULL) 249 while ((fgets(path, _POSIX_PATH_MAX, fp)) != NULL)
247 if (*path == '/') { 250 if (*path == '/') {
248 if ((p = strrchr(path, '\r')) != NULL) 251 if ((p = strrchr(path, '\r')) != NULL)
249 *p = 0; 252 *p = 0;
250 if ((p = strrchr(path, '\n')) != NULL) 253 if ((p = strrchr(path, '\n')) != NULL)
251 *p = 0; 254 *p = 0;
255 if (!scan_l && !strcmp(path, "/lib")) scan_l = 1;
256 if (!scan_ul && !strcmp(path, "/usr/lib")) scan_ul = 1;
257 if (!scan_ull && !strcmp(path, "/usr/local/lib")) scan_ull = 1;
252 scanelf_dir(path); 258 scanelf_dir(path);
253 } 259 }
254 free(path); 260 free(path);
261
262 if (!scan_l) scanelf_dir("/lib");
263 if (!scan_ul) scanelf_dir("/usr/lib");
264 if (!scan_ull) scanelf_dir("/usr/local/lib");
255 265
256 fclose(fp); 266 fclose(fp);
257} 267}
258 268
259/* scan env PATH for paths */ 269/* scan env PATH for paths */
270 280
271 while ((p = strrchr(path, ':')) != NULL) { 281 while ((p = strrchr(path, ':')) != NULL) {
272 scanelf_dir(p + 1); 282 scanelf_dir(p + 1);
273 *p = 0; 283 *p = 0;
274 } 284 }
285
275 free(path); 286 free(path);
276} 287}
277 288
278 289
279 290

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.20