public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:master commit in: src/, /
Date: Sat, 10 Nov 2012 19:31:12 +0000 (UTC)	[thread overview]
Message-ID: <1352575850.193fe870825aa2e2b738acd6c2bd7fd4c4698ca9.blueness@gentoo> (raw)

commit:     193fe870825aa2e2b738acd6c2bd7fd4c4698ca9
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 10 19:30:50 2012 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Nov 10 19:30:50 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=193fe870

configure.ac: clean up checks for ptpax, xtpax

---
 configure.ac    |   90 +++++++++++++++++++++++++------------------------------
 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;


             reply	other threads:[~2012-11-10 19:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-10 19:31 Anthony G. Basile [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-06-07 11:56 [gentoo-commits] proj/elfix:master commit in: src/, / Anthony G. Basile
2012-11-10 23:19 Anthony G. Basile
2012-11-10 20:02 Anthony G. Basile
2011-11-03 11:13 Anthony G. Basile

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1352575850.193fe870825aa2e2b738acd6c2bd7fd4c4698ca9.blueness@gentoo \
    --to=blueness@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox