diff options
author | Anthony G. Basile <basile@opensource.dyc.edu> | 2011-05-05 19:50:15 -0400 |
---|---|---|
committer | Anthony G. Basile <basile@opensource.dyc.edu> | 2011-05-05 19:50:15 -0400 |
commit | 646f75362042124158b075efb3c7eb8cd779539f (patch) | |
tree | ef8902009f3f7ab9aa84a753999e508bdcaba3be | |
parent | src/fix-gnustack.c: improved error messages (diff) | |
download | elfix-646f75362042124158b075efb3c7eb8cd779539f.tar.gz elfix-646f75362042124158b075efb3c7eb8cd779539f.tar.bz2 elfix-646f75362042124158b075efb3c7eb8cd779539f.zip |
poc/mangle-paxflags.c and src/fix-gnustack.c: added help option
-rwxr-xr-x | autogen.sh | 1 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | poc/mangle-paxflags.c | 29 | ||||
-rw-r--r-- | src/fix-gnustack.c | 26 |
4 files changed, 53 insertions, 7 deletions
@@ -1,5 +1,6 @@ #!/bin/sh aclocal && \ +autoheader && \ autoconf && \ automake --add-missing --copy diff --git a/configure.ac b/configure.ac index 039a269..560cc82 100644 --- a/configure.ac +++ b/configure.ac @@ -2,9 +2,9 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) -AC_INIT([elfix], [0.1], [blueness@gentoo.org]) +AC_INIT([elfix], [0.1.3], [http://bugs.gentoo.org/]) AC_CONFIG_SRCDIR([src/fix-gnustack.c]) -#AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([1.11 foreign]) AC_ARG_ENABLE( diff --git a/poc/mangle-paxflags.c b/poc/mangle-paxflags.c index 8853b13..301dad7 100644 --- a/poc/mangle-paxflags.c +++ b/poc/mangle-paxflags.c @@ -28,6 +28,8 @@ #include <fcntl.h> #include <unistd.h> +#include <config.h> + // From chpax.h #define EI_PAX 14 // Index in e_ident[] where to read flags #define HF_PAX_PAGEEXEC 1 // 0: Paging based non-exec pages @@ -37,22 +39,40 @@ #define HF_PAX_RANDEXEC 16 // 1: Randomize ET_EXEC base #define HF_PAX_SEGMEXEC 32 // 0: Segmentation based non-exec pages - #define PRINT(E,F,I) printf("%s:\t%s\n", #E, E & F ? ( I ? "enabled" : "disabled" ) : ( I ? "disabled" : "enabled" ) ); #define CASE(N,P) case P: printf("%d: %s\n", (int)N, #P); break +void +print_help(char *v) +{ + printf( + "Package Name : " PACKAGE_STRING "\n" + "Bug Reports : " PACKAGE_BUGREPORT "\n" + "Description : Check for, or conditionally remove, executable flag from PT_GNU_STACK\n\n" + "Usage : %s {-h | [-e] [-p] ELFfile}\n" + "options : Print out EI_PAX and PT_PAX_FLAGS information\n" + " : -e Set all EI_PAX flags to least secure setting, pEmrXs\n" + " : -p Remove PT_PAX_FLAGS program header\n" + " : -h Print out this help\n", + v + ); + + exit(EXIT_SUCCESS); +} + + char * parse_cmd_args( int c, char *v[], int *flag_ei_pax, int *flag_pt_pax_flags ) { int i, oc; if((c != 2)&&(c != 3)&&(c != 4)) - error(EXIT_FAILURE, 0, "Usage: %s [-e] [-p] elffile", v[0]); + error(EXIT_FAILURE, 0, "Usage: %s {[-e] [-p] ELFfile | [-h]}", v[0]); *flag_ei_pax = 0; *flag_pt_pax_flags = 0; - while((oc = getopt(c, v,":ep")) != -1) + while((oc = getopt(c, v,":eph")) != -1) switch(oc) { case 'e': @@ -61,6 +81,9 @@ parse_cmd_args( int c, char *v[], int *flag_ei_pax, int *flag_pt_pax_flags ) case 'p': *flag_pt_pax_flags = 1; break; + case 'h': + print_help(v[0]); + break; case '?': default: error(EXIT_FAILURE, 0, "option -%c is invalid: ignored.", optopt ) ; diff --git a/src/fix-gnustack.c b/src/fix-gnustack.c index 75d72ea..02eb4d5 100644 --- a/src/fix-gnustack.c +++ b/src/fix-gnustack.c @@ -28,6 +28,25 @@ #include <fcntl.h> #include <unistd.h> +#include <config.h> + + +void +print_help(char *v) +{ + printf( + "Package Name : " PACKAGE_STRING "\n" + "Bug Reports : " PACKAGE_BUGREPORT "\n" + "Description : Check for, or conditionally remove, executable flag from PT_GNU_STACK\n\n" + "Usage : %s {[-f] ELFfile | [-h]}\n" + "options : Print out protection flags on PT_GNU_STACK\n" + " : -f Remove X if WX flags are set on PT_GNU_STACK\n" + " : -h Print out this help\n", + v + ); + + exit(EXIT_SUCCESS); +} char * @@ -36,15 +55,18 @@ parse_cmd_args( int c, char *v[], int *flagv ) int i, oc; if((c != 2)&&(c != 3)) - error(EXIT_FAILURE, 0, "Usage: %s [-f] elffile", v[0]); + error(EXIT_FAILURE, 0, "Usage: %s {-h | [-f] ELFfile}", v[0]); *flagv = 0 ; - while((oc = getopt(c, v,":f")) != -1) + while((oc = getopt(c, v,":fh")) != -1) switch(oc) { case 'f': *flagv = 1 ; break ; + case 'h': + print_help(v[0]); + break; case '?': default: error(EXIT_FAILURE, 0, "option -%c is invalid: ignored.", optopt ) ; |