/[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.103 Revision 1.104
1/* 1/*
2 * Copyright 2003-2006 Gentoo Foundation 2 * Copyright 2003-2006 Gentoo Foundation
3 * Distributed under the terms of the GNU General Public License v2 3 * Distributed under the terms of the GNU General Public License v2
4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/Attic/scanelf.c,v 1.103 2006/01/11 23:46:21 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/Attic/scanelf.c,v 1.104 2006/01/13 11:31:55 vapier Exp $
5 * 5 *
6 * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org> 6 * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org>
7 * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org> 7 * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org>
8 */ 8 */
9 9
10#include "paxinc.h" 10#include "paxinc.h"
11 11
12static const char *rcsid = "$Id: scanelf.c,v 1.103 2006/01/11 23:46:21 vapier Exp $"; 12static const char *rcsid = "$Id: scanelf.c,v 1.104 2006/01/13 11:31:55 vapier Exp $";
13#define argv0 "scanelf" 13#define argv0 "scanelf"
14 14
15#define IS_MODIFIER(c) (c == '%' || c == '#') 15#define IS_MODIFIER(c) (c == '%' || c == '#')
16 16
17 17
551static char *lookup_cache_lib(elfobj *, char *); 551static char *lookup_cache_lib(elfobj *, char *);
552static char *lookup_cache_lib(elfobj *elf, char *fname) 552static char *lookup_cache_lib(elfobj *elf, char *fname)
553{ 553{
554 int fd = 0; 554 int fd = 0;
555 char *strs; 555 char *strs;
556 static char buf[_POSIX_PATH_MAX] = ""; 556 static char buf[__PAX_UTILS_PATH_MAX] = "";
557 const char *cachefile = "/etc/ld.so.cache"; 557 const char *cachefile = "/etc/ld.so.cache";
558 struct stat st; 558 struct stat st;
559 559
560 typedef struct { 560 typedef struct {
561 char magic[LDSO_CACHE_MAGIC_LEN]; 561 char magic[LDSO_CACHE_MAGIC_LEN];
877 found_rpath = found_needed = found_interp = found_bind = found_soname = \ 877 found_rpath = found_needed = found_interp = found_bind = found_soname = \
878 found_sym = found_lib = found_file = found_textrels = 0; 878 found_sym = found_lib = found_file = found_textrels = 0;
879 879
880 /* verify this is real ELF */ 880 /* verify this is real ELF */
881 if ((elf = _readelf(filename, !fix_elf)) == NULL) { 881 if ((elf = _readelf(filename, !fix_elf)) == NULL) {
882 /* if it isn't an ELF, maybe it's an .a archive */
883 archive_handle *ar = ar_open(filename);
882 if (be_verbose > 2) printf("%s: not an ELF\n", filename); 884 if (be_verbose > 2) printf("%s: not an ELF\n", filename);
883 return; 885 return;
884 } 886 }
885 887
886 if (be_verbose > 1) 888 if (be_verbose > 1)
1019static void scanelf_dir(const char *path) 1021static void scanelf_dir(const char *path)
1020{ 1022{
1021 register DIR *dir; 1023 register DIR *dir;
1022 register struct dirent *dentry; 1024 register struct dirent *dentry;
1023 struct stat st_top, st; 1025 struct stat st_top, st;
1024 char buf[_POSIX_PATH_MAX]; 1026 char buf[__PAX_UTILS_PATH_MAX];
1025 size_t pathlen = 0, len = 0; 1027 size_t pathlen = 0, len = 0;
1026 1028
1027 /* make sure path exists */ 1029 /* make sure path exists */
1028 if (lstat(path, &st_top) == -1) { 1030 if (lstat(path, &st_top) == -1) {
1029 if (be_verbose > 2) printf("%s: does not exist\n", path); 1031 if (be_verbose > 2) printf("%s: does not exist\n", path);
1068 1070
1069static int scanelf_from_file(char *filename) 1071static int scanelf_from_file(char *filename)
1070{ 1072{
1071 FILE *fp = NULL; 1073 FILE *fp = NULL;
1072 char *p; 1074 char *p;
1073 char path[_POSIX_PATH_MAX]; 1075 char path[__PAX_UTILS_PATH_MAX];
1074 1076
1075 if (((strcmp(filename, "-")) == 0) && (ttyname(0) == NULL)) 1077 if (((strcmp(filename, "-")) == 0) && (ttyname(0) == NULL))
1076 fp = stdin; 1078 fp = stdin;
1077 else if ((fp = fopen(filename, "r")) == NULL) 1079 else if ((fp = fopen(filename, "r")) == NULL)
1078 return 1; 1080 return 1;
1079 1081
1080 while ((fgets(path, _POSIX_PATH_MAX, fp)) != NULL) { 1082 while ((fgets(path, __PAX_UTILS_PATH_MAX, fp)) != NULL) {
1081 if ((p = strchr(path, '\n')) != NULL) 1083 if ((p = strchr(path, '\n')) != NULL)
1082 *p = 0; 1084 *p = 0;
1083 search_path = path; 1085 search_path = path;
1084 scanelf_dir(path); 1086 scanelf_dir(path);
1085 } 1087 }
1090 1092
1091static void load_ld_so_conf() 1093static void load_ld_so_conf()
1092{ 1094{
1093 FILE *fp = NULL; 1095 FILE *fp = NULL;
1094 char *p; 1096 char *p;
1095 char path[_POSIX_PATH_MAX]; 1097 char path[__PAX_UTILS_PATH_MAX];
1096 int i = 0; 1098 int i = 0;
1097 1099
1098 if ((fp = fopen("/etc/ld.so.conf", "r")) == NULL) 1100 if ((fp = fopen("/etc/ld.so.conf", "r")) == NULL)
1099 return; 1101 return;
1100 1102
1101 while ((fgets(path, _POSIX_PATH_MAX, fp)) != NULL) { 1103 while ((fgets(path, __PAX_UTILS_PATH_MAX, fp)) != NULL) {
1102 if (*path != '/') 1104 if (*path != '/')
1103 continue; 1105 continue;
1104 1106
1105 if ((p = strrchr(path, '\r')) != NULL) 1107 if ((p = strrchr(path, '\r')) != NULL)
1106 *p = 0; 1108 *p = 0;

Legend:
Removed from v.1.103  
changed lines
  Added in v.1.104

  ViewVC Help
Powered by ViewVC 1.1.20