diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2012-11-10 14:30:50 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2012-11-10 14:30:50 -0500 |
commit | 193fe870825aa2e2b738acd6c2bd7fd4c4698ca9 (patch) | |
tree | 8c66f74f5790492a4fcd7f510d173387e644cb4a | |
parent | Work towards making both PT_PAX and xattr PAX optional (diff) | |
download | elfix-193fe870825aa2e2b738acd6c2bd7fd4c4698ca9.tar.gz elfix-193fe870825aa2e2b738acd6c2bd7fd4c4698ca9.tar.bz2 elfix-193fe870825aa2e2b738acd6c2bd7fd4c4698ca9.zip |
configure.ac: clean up checks for ptpax, xtpax
-rw-r--r-- | configure.ac | 90 | ||||
-rw-r--r-- | src/paxctl-ng.c | 53 |
2 files changed, 78 insertions, 65 deletions
diff --git a/configure.ac b/configure.ac index f0299a8..bfbe367 100644 --- a/configure.ac +++ b/configure.ac @@ -48,37 +48,33 @@ AC_ARG_ENABLE( AS_HELP_STRING( [--enable-ptpax], [enable support for pax markings in PT_PAX ELF phdr] - ), + ) +) + +AS_IF( + [test "x$enable_ptpax" != "xno"], [ - AS_IF( - [test "x$enable_ptpax" = "xyes"], - [ - AC_CHECK_HEADERS( - [gelf.h], - [], - [AC_MSG_ERROR(["Missing necessary gelf.h"])] - ) - AC_CHECK_DECLS( - [PT_PAX_FLAGS, PF_PAGEEXEC, PF_MPROTECT, PF_RANDMMAP], - [], - [AC_MSG_ERROR(["Missing necessary function elf_begin in libelf"])], - [[#include <gelf.h>]] - ) - AC_CHECK_LIB( - [elf], - [elf_begin], - [], - [AC_MSG_ERROR(["Missing necessary function elf_begin in libelf"])] - ) - CFLAGS+=" -DPTPAX" - ], - [ - CFLAGS+=" -UPTPAX" - ] + AC_CHECK_HEADERS( + [gelf.h], + [], + [AC_MSG_ERROR(["Missing necessary gelf.h"])] + ) + AC_CHECK_DECLS( + [PT_PAX_FLAGS, PF_PAGEEXEC, PF_MPROTECT, PF_RANDMMAP], + [], + [AC_MSG_ERROR(["Missing necessary function elf_begin in libelf"])], + [[#include <gelf.h>]] ) + AC_CHECK_LIB( + [elf], + [elf_begin], + [], + [AC_MSG_ERROR(["Missing necessary function elf_begin in libelf"])] + ) + CFLAGS+=" -DPTPAX" ], [ - CFLAGS+=" -DPTPAX" + CFLAGS+=" -UPTPAX" ] ) @@ -87,35 +83,31 @@ AC_ARG_ENABLE( AS_HELP_STRING( [--enable-xtpax], [enable support for pax markings in xattrs] - ), + ) +) + +AS_IF( + [test "x$enable_xtpax" != "xno"], [ - AS_IF( - [test "x$enable_xtpax" = "xyes"], - [ - AC_CHECK_HEADERS( - [attr/xattr.h], - [], - [AC_MSG_ERROR(["Missing necessary attr/xattr.h"])] - ) - AC_CHECK_LIB( - [attr], - [fgetxattr], - [], - [AC_MSG_ERROR(["Missing necessary function fgetxattr in libattr"])] - ) - CFLAGS+=" -DXTPAX" - ], - [ - CFLAGS+=" -UXTPAX" - ] + AC_CHECK_HEADERS( + [attr/xattr.h], + [], + [AC_MSG_ERROR(["Missing necessary attr/xattr.h"])] ) + AC_CHECK_LIB( + [attr], + [fgetxattr], + [], + [AC_MSG_ERROR(["Missing necessary function fgetxattr in libattr"])] + ) + CFLAGS+=" -DXTPAX" ], [ - CFLAGS+=" -DXTPAX" + CFLAGS+=" -UXTPAX" ] ) -if [test "x$enable_ptpax" != "xyes" -a "x$enable_xtpax" != "xyes" ]; then +if [test "x$enable_ptpax" = "xno" -a "x$enable_xtpax" = "xno" ]; then AC_MSG_ERROR(["You must enable either ptpax or xtpax"]) fi diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c index b467c2a..d1bddda 100644 --- a/src/paxctl-ng.c +++ b/src/paxctl-ng.c @@ -22,30 +22,29 @@ #include <string.h> #include <error.h> #include <libgen.h> - -#include <gelf.h> - -#ifdef XTPAX -#include <attr/xattr.h> -#endif - #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> -#include <config.h> +#ifdef PTPAX + #include <gelf.h> +#endif #ifdef XTPAX -#define PAX_NAMESPACE "user.pax.flags" + #include <attr/xattr.h> + + #define PAX_NAMESPACE "user.pax.flags" -#define CREATE_XT_FLAGS_SECURE 1 -#define CREATE_XT_FLAGS_DEFAULT 2 -#define COPY_PT_TO_XT_FLAGS 3 -#define COPY_XT_TO_PT_FLAGS 4 + #define CREATE_XT_FLAGS_SECURE 1 + #define CREATE_XT_FLAGS_DEFAULT 2 + #define COPY_PT_TO_XT_FLAGS 3 + #define COPY_XT_TO_PT_FLAGS 4 #endif -#define FLAGS_SIZE 6 +#define FLAGS_SIZE 6 + +#include <config.h> void print_help_exit(char *v) @@ -58,7 +57,10 @@ print_help_exit(char *v) "Description : Get or set pax flags on an ELF object\n\n" "Usage : %s -PpSsMmEeRrv ELF | -Zv ELF | -zv ELF\n" #ifdef XTPAX - " : %s -Cv ELF | -cv ELF | -Fv ELF | -fv ELF\n" + " : %s -Cv ELF | -cv ELF\n" +#endif +#if defined(PTPAX) && defined(XTPAX) + " : %s -Fv ELF | -fv ELF\n" #endif " : %s -v ELF | -h\n\n" "Options : -P enable PAGEEXEC\t-p disable PAGEEXEC\n" @@ -70,6 +72,8 @@ print_help_exit(char *v) #ifdef XTPAX " : -C create XT_PAX with most secure setting\n" " : -c create XT_PAX all default settings\n" +#endif +#if defined(PTPAX) && defined(XTPAX) " : -F copy PT_PAX to XT_PAX\n" " : -f copy XT_PAX to PT_PAX\n" #endif @@ -78,7 +82,12 @@ print_help_exit(char *v) "Note : If both enabling and disabling flags are set, the default - is used\n\n", basename(v), basename(v), +#ifdef XTPAX + basename(v), +#endif +#if defined(PTPAX) && defined(XTPAX) basename(v), +#endif basename(v) ); @@ -98,11 +107,21 @@ parse_cmd_args(int argc, char *argv[], uint16_t *pax_flags, int *verbose, int *c *pax_flags = 0; *verbose = 0; *cp_flags = 0; -#ifdef XTPAX + +/* +#if !defined(PTPAX) && defined(XTPAX) + while((oc = getopt(argc, argv,":PpSsMmEeRrZzCcvh")) != -1) +#elif defined(PTPAX) && defined(XTPAX) while((oc = getopt(argc, argv,":PpSsMmEeRrZzCcFfvh")) != -1) #else while((oc = getopt(argc, argv,":PpSsMmEeRrZzvh")) != -1) #endif +*/ + + //Accept all options and silently ignore irrelevant ones below + //so we can pass any parameter in scripts + + while((oc = getopt(argc, argv,":PpSsMmEeRrZzCcFfvh")) != -1) { switch(oc) { @@ -166,6 +185,8 @@ parse_cmd_args(int argc, char *argv[], uint16_t *pax_flags, int *verbose, int *c solitaire += 1; *cp_flags = CREATE_XT_FLAGS_DEFAULT; break; +#endif +#if defined(PTPAX) && defined(XTPAX) case 'F': solitaire += 1; *cp_flags = COPY_PT_TO_XT_FLAGS; |