/[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.164 Revision 1.165
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/scanelf.c,v 1.164 2006/12/03 00:17:18 solar Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.165 2006/12/11 03:24:03 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.164 2006/12/03 00:17:18 solar Exp $"; 12static const char *rcsid = "$Id: scanelf.c,v 1.165 2006/12/11 03:24:03 vapier Exp $";
13#define argv0 "scanelf" 13#define argv0 "scanelf"
14 14
15#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') 15#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+')
16
17#define do_state(option, flag) \
18 if (islower(option)) { \
19 flags &= ~PF_##flag; \
20 flags |= PF_NO##flag; \
21 } else { \
22 flags &= ~PF_NO##flag; \
23 flags |= PF_##flag; \
24 }
25
26 16
27/* prototypes */ 17/* prototypes */
28static int file_matches_list(const char *filename, char **matchlist); 18static int file_matches_list(const char *filename, char **matchlist);
29static int scanelf_elfobj(elfobj *elf); 19static int scanelf_elfobj(elfobj *elf);
30static int scanelf_elf(const char *filename, int fd, size_t len); 20static int scanelf_elf(const char *filename, int fd, size_t len);
1603 1593
1604 exit(status); 1594 exit(status);
1605} 1595}
1606 1596
1607/* parse command line arguments and preform needed actions */ 1597/* parse command line arguments and preform needed actions */
1598#define do_pax_state(option, flag) \
1599 if (islower(option)) { \
1600 flags &= ~PF_##flag; \
1601 flags |= PF_NO##flag; \
1602 } else { \
1603 flags &= ~PF_NO##flag; \
1604 flags |= PF_##flag; \
1605 }
1608static int parseargs(int argc, char *argv[]) 1606static int parseargs(int argc, char *argv[])
1609{ 1607{
1610 int i; 1608 int i;
1611 const char *from_file = NULL; 1609 const char *from_file = NULL;
1612 int ret = 0; 1610 int ret = 0;
1665 1663
1666 for (x = 0 ; x < strlen(optarg); x++) { 1664 for (x = 0 ; x < strlen(optarg); x++) {
1667 switch(optarg[x]) { 1665 switch(optarg[x]) {
1668 case 'p': 1666 case 'p':
1669 case 'P': 1667 case 'P':
1670 do_state(optarg[x], PAGEEXEC); 1668 do_pax_state(optarg[x], PAGEEXEC);
1671 break; 1669 break;
1672 case 's': 1670 case 's':
1673 case 'S': 1671 case 'S':
1674 do_state(optarg[x], SEGMEXEC); 1672 do_pax_state(optarg[x], SEGMEXEC);
1675 break; 1673 break;
1676 case 'm': 1674 case 'm':
1677 case 'M': 1675 case 'M':
1678 do_state(optarg[x], MPROTECT); 1676 do_pax_state(optarg[x], MPROTECT);
1679 break; 1677 break;
1680 case 'e': 1678 case 'e':
1681 case 'E': 1679 case 'E':
1682 do_state(optarg[x], EMUTRAMP); 1680 do_pax_state(optarg[x], EMUTRAMP);
1683 break; 1681 break;
1684 case 'r': 1682 case 'r':
1685 case 'R': 1683 case 'R':
1686 do_state(optarg[x], RANDMMAP); 1684 do_pax_state(optarg[x], RANDMMAP);
1687 break; 1685 break;
1688 case 'x': 1686 case 'x':
1689 case 'X': 1687 case 'X':
1690 do_state(optarg[x], RANDEXEC); 1688 do_pax_state(optarg[x], RANDEXEC);
1691 break; 1689 break;
1692 default: 1690 default:
1693 break; 1691 break;
1694 } 1692 }
1695 } 1693 }

Legend:
Removed from v.1.164  
changed lines
  Added in v.1.165

  ViewVC Help
Powered by ViewVC 1.1.20