diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2011-09-10 21:54:00 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2011-09-10 21:54:00 -0400 |
commit | 9479f0ca040e95f24da74818242850f0cf8fff29 (patch) | |
tree | bbe0c12d352ae9c044bd248eab3eed9eab2f5b72 /src | |
parent | src/paxctl-ng.c: added read EI/PT_PAX flags (diff) | |
download | elfix-9479f0ca040e95f24da74818242850f0cf8fff29.tar.gz elfix-9479f0ca040e95f24da74818242850f0cf8fff29.tar.bz2 elfix-9479f0ca040e95f24da74818242850f0cf8fff29.zip |
src/paxctl-ng.c: construct pax flags from command line
Diffstat (limited to 'src')
-rw-r--r-- | src/paxctl-ng.c | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c index d7c58a5..c7206c3 100644 --- a/src/paxctl-ng.c +++ b/src/paxctl-ng.c @@ -50,7 +50,7 @@ print_help(char *v) "Bug Reports : " PACKAGE_BUGREPORT "\n" "Program Name : %s\n" "Description : Get or set pax flags on an ELF object\n\n" - "Usage : %s {[-pPeEmMrRxXsSzZC] ELFfile | [-h]}\n" + "Usage : %s {[-PpEeMmRrXxSsZzv] ELFfile | [-h]}\n" "options : Print out pax flag information\n" " : -p Disable PAGEEXEC\t-P Enable PAGEEXEC\n" " : -e Disable EMUTRAMP\t-E Enable EMUTRAMP\n" @@ -74,41 +74,54 @@ parse_cmd_args(int c, char *v[], int *pax_flags, int *view_flags) { int i, oc; - if((c != 2)&&(c != 3)&&(c != 4)) - error(EXIT_FAILURE, 0, "Usage: %s {[-pPeEmMrRxXsSzZv] ELFfile | [-h]}", v[0]); - *pax_flags = 0; *view_flags = 0; - while((oc = getopt(c, v,":pPeEmMrRxXsSzZvh")) != -1) + while((oc = getopt(c, v,":PpEeMmRrXxSsZzvh")) != -1) switch(oc) { + case 'P': + *pax_flags |= PF_PAGEEXEC; + break; case 'p': + *pax_flags |= PF_NOPAGEEXEC; break ; - case 'P': + case 'S': + *pax_flags |= PF_SEGMEXEC; break; - case 'e': + case 's': + *pax_flags |= PF_NOSEGMEXEC; break ; - case 'E': + case 'M': + *pax_flags |= PF_MPROTECT; break; case 'm': + *pax_flags |= PF_NOMPROTECT; break ; - case 'M': + case 'E': + *pax_flags |= PF_EMUTRAMP; break; - case 'r': + case 'e': + *pax_flags |= PF_NOEMUTRAMP; break ; case 'R': + *pax_flags |= PF_RANDMMAP; break; - case 'x': + case 'r': + *pax_flags |= PF_NORANDMMAP; break ; case 'X': + *pax_flags |= PF_RANDEXEC; break; - case 's': - break ; - case 'S': - break; - case 'z': + case 'x': + *pax_flags |= PF_NORANDEXEC; break ; case 'Z': + *pax_flags = PF_PAGEEXEC | PF_SEGMEXEC | PF_MPROTECT | + PF_NOEMUTRAMP | PF_RANDMMAP | PF_RANDEXEC; + break ; + case 'z': + *pax_flags = PF_NOPAGEEXEC | PF_NOSEGMEXEC | PF_NOMPROTECT | + PF_EMUTRAMP | PF_NORANDMMAP | PF_NORANDEXEC; break; case 'v': *view_flags = 1; @@ -121,6 +134,12 @@ parse_cmd_args(int c, char *v[], int *pax_flags, int *view_flags) error(EXIT_FAILURE, 0, "option -%c is invalid: ignored.", optopt ) ; } +// if((c != 2)&&(c != 3)&&(c != 4)) +// error(EXIT_FAILURE, 0, "Usage: %s {[-pPeEmMrRxXsSzZv] ELFfile | [-h]}", v[0]); + + if(v[optind] == NULL) + error(EXIT_FAILURE, 0, "Usage: %s {[-pPeEmMrRxXsSzZv] ELFfile | [-h]}", v[0]); + return v[optind] ; } |