| 1 | /* |
1 | /* |
| 2 | * Copyright 2003-2007 Gentoo Foundation |
2 | * Copyright 2003-2007 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/scanelf.c,v 1.227 2011/09/27 19:20:51 vapier Exp $ |
4 | * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.228 2011/09/27 19:21:56 vapier Exp $ |
| 5 | * |
5 | * |
| 6 | * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org> |
6 | * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org> |
| 7 | * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org> |
7 | * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org> |
| 8 | */ |
8 | */ |
| 9 | |
9 | |
| 10 | static const char *rcsid = "$Id: scanelf.c,v 1.227 2011/09/27 19:20:51 vapier Exp $"; |
10 | static const char *rcsid = "$Id: scanelf.c,v 1.228 2011/09/27 19:21:56 vapier Exp $"; |
| 11 | const char argv0[] = "scanelf"; |
11 | const char argv0[] = "scanelf"; |
| 12 | |
12 | |
| 13 | #include "paxinc.h" |
13 | #include "paxinc.h" |
| 14 | |
14 | |
| 15 | #define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') |
15 | #define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') |
| … | |
… | |
| 27 | static char **get_split_env(const char *envvar); |
27 | static char **get_split_env(const char *envvar); |
| 28 | static void parseenv(void); |
28 | static void parseenv(void); |
| 29 | static int parseargs(int argc, char *argv[]); |
29 | static int parseargs(int argc, char *argv[]); |
| 30 | |
30 | |
| 31 | /* variables to control behavior */ |
31 | /* variables to control behavior */ |
| 32 | static char match_etypes[126] = ""; |
32 | static char *match_etypes = NULL; |
| 33 | static array_t _ldpaths = array_init_decl, *ldpaths = &_ldpaths; |
33 | static array_t _ldpaths = array_init_decl, *ldpaths = &_ldpaths; |
| 34 | static char scan_ldpath = 0; |
34 | static char scan_ldpath = 0; |
| 35 | static char scan_envpath = 0; |
35 | static char scan_envpath = 0; |
| 36 | static char scan_symlink = 1; |
36 | static char scan_symlink = 1; |
| 37 | static char scan_archives = 0; |
37 | static char scan_archives = 0; |
| … | |
… | |
| 1446 | if (elf->elf_class != ELFCLASS64) |
1446 | if (elf->elf_class != ELFCLASS64) |
| 1447 | goto label_done; |
1447 | goto label_done; |
| 1448 | break; |
1448 | break; |
| 1449 | default: break; |
1449 | default: break; |
| 1450 | } |
1450 | } |
| 1451 | if (strlen(match_etypes)) { |
1451 | if (match_etypes) { |
| 1452 | char sbuf[126]; |
1452 | char sbuf[126]; |
| 1453 | strncpy(sbuf, match_etypes, sizeof(sbuf)); |
1453 | strncpy(sbuf, match_etypes, sizeof(sbuf)); |
| 1454 | if (strchr(match_etypes, ',') != NULL) { |
1454 | if (strchr(match_etypes, ',') != NULL) { |
| 1455 | char *p; |
1455 | char *p; |
| 1456 | while ((p = strrchr(sbuf, ',')) != NULL) { |
1456 | while ((p = strrchr(sbuf, ',')) != NULL) { |
| … | |
… | |
| 1913 | case 'f': |
1913 | case 'f': |
| 1914 | if (from_file) warn("You prob don't want to specify -f twice"); |
1914 | if (from_file) warn("You prob don't want to specify -f twice"); |
| 1915 | from_file = optarg; |
1915 | from_file = optarg; |
| 1916 | break; |
1916 | break; |
| 1917 | case 'E': |
1917 | case 'E': |
| 1918 | strncpy(match_etypes, optarg, sizeof(match_etypes)); |
1918 | match_etypes = optarg; |
| 1919 | break; |
1919 | break; |
| 1920 | case 'M': |
1920 | case 'M': |
| 1921 | match_bits = atoi(optarg); |
1921 | match_bits = atoi(optarg); |
| 1922 | if (match_bits == 0) { |
1922 | if (match_bits == 0) { |
| 1923 | if (strcmp(optarg, "ELFCLASS32") == 0) |
1923 | if (strcmp(optarg, "ELFCLASS32") == 0) |