public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/elfix:master commit in: src/, scripts/, /
@ 2011-10-08 18:13 Anthony G. Basile
  0 siblings, 0 replies; 5+ messages in thread
From: Anthony G. Basile @ 2011-10-08 18:13 UTC (permalink / raw
  To: gentoo-commits

commit:     0a18a5e10b503a003ab076848ade2d94347b6e40
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Oct  8 18:12:56 2011 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Oct  8 18:12:56 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=0a18a5e1

{scripts,src}/Makefile.am: install all utilities into /sbin

---
 Makefile.am         |    2 +-
 configure.ac        |    1 +
 scripts/Makefile.am |    1 +
 src/Makefile.am     |    2 +-
 4 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index fbec9a2..f092f0d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,4 +4,4 @@ endif
 if POC
 SUBDIRS_POC = poc
 endif
-SUBDIRS = src doc $(SUBDIRS_TESTS) $(SUBDIRS_POC)
+SUBDIRS = src scripts doc $(SUBDIRS_TESTS) $(SUBDIRS_POC)

diff --git a/configure.ac b/configure.ac
index bc6e0f6..b9731b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,6 +64,7 @@ AC_FUNC_ERROR_AT_LINE
 
 AC_CONFIG_FILES([Makefile
                  src/Makefile
+                 scripts/Makefile
                  doc/Makefile
                  poc/Makefile
                  tests/Makefile])

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
new file mode 100644
index 0000000..9faaeac
--- /dev/null
+++ b/scripts/Makefile.am
@@ -0,0 +1 @@
+sbin_SCRIPTS = revdep-pax

diff --git a/src/Makefile.am b/src/Makefile.am
index 8e4709c..cc46fe2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-bin_PROGRAMS = fix-gnustack paxctl-ng
+sbin_PROGRAMS = fix-gnustack paxctl-ng
 fix_gnustack_SOURCES = fix-gnustack.c
 fix_gnustack_LDADD = -lelf
 paxctl_ng_SOURCES = paxctl-ng.c



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [gentoo-commits] proj/elfix:master commit in: src/, scripts/, /
@ 2011-10-20 19:03 Anthony G. Basile
  0 siblings, 0 replies; 5+ messages in thread
From: Anthony G. Basile @ 2011-10-20 19:03 UTC (permalink / raw
  To: gentoo-commits

commit:     bcf0f80a9365e40b31109ca01462d5a2a3a5eae7
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 20 19:03:08 2011 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Thu Oct 20 19:03:08 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=bcf0f80a

Update build system

---
 configure.ac     |   22 +++++++++-------------
 scripts/setup.py |    2 +-
 src/Makefile.am  |    2 --
 src/paxctl-ng.c  |    4 +---
 4 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/configure.ac b/configure.ac
index fa669ec..592d346 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,28 +27,24 @@ AM_CONDITIONAL([TEST],[test "x$has_yasm" = "xyes"])
 
 # Checks for programs.
 AC_PROG_CC
-AC_CHECK_FUNCS([strerror])
+AC_CHECK_FUNCS([memset strerror])
 AC_FUNC_MMAP
 
 # Checks for libraries.
 AC_CHECK_LIB([elf], [elf_begin])
+AC_CHECK_LIB([attr], [fgetxattr])
 
 # Checks for header files.
-AC_CHECK_HEADERS([errno.h])
-AC_CHECK_HEADERS([error.h])
-AC_CHECK_HEADERS([fcntl.h])
-AC_CHECK_HEADERS([gelf.h])
-AC_CHECK_HEADERS([libgen.h])
-AC_CHECK_HEADERS([stdio.h])
-AC_CHECK_HEADERS([stdlib.h])
-AC_CHECK_HEADERS([string.h])
-AC_CHECK_HEADERS([sys/mman.h])
-AC_CHECK_HEADERS([sys/stat.h])
-AC_CHECK_HEADERS([sys/types.h])
-AC_CHECK_HEADERS([unistd.h])
+
+AC_CHECK_HEADERS([attr/xattr.h errno.h error.h fcntl.h gelf.h libgen.h stdio.h \
+	stdlib.h string.h sys/mman.h sys/stat.h sys/types.h unistd.h
+],
+[], [AC_MSG_ERROR(["Missing necessary header"])])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_TYPE_SIZE_T
+AC_TYPE_UINT8_T
+AC_TYPE_UINT16_T
 
 # Checks for library functions.
 AC_FUNC_ERROR_AT_LINE

diff --git a/scripts/setup.py b/scripts/setup.py
index 77854f1..3170930 100755
--- a/scripts/setup.py
+++ b/scripts/setup.py
@@ -5,7 +5,7 @@ from distutils.core import setup, Extension
 module1 = Extension(
 	name='pax',
 	sources = ['paxmodule.c'],
-	libraries = ['elf'],
+	libraries = ['elf', 'attr'],
 )
 
 setup(

diff --git a/src/Makefile.am b/src/Makefile.am
index cc46fe2..de2d157 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,5 +1,3 @@
 sbin_PROGRAMS = fix-gnustack paxctl-ng
 fix_gnustack_SOURCES = fix-gnustack.c
-fix_gnustack_LDADD = -lelf
 paxctl_ng_SOURCES = paxctl-ng.c
-paxctl_ng_LDADD = -lelf

diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c
index 8d9bf55..dccd8ac 100644
--- a/src/paxctl-ng.c
+++ b/src/paxctl-ng.c
@@ -205,10 +205,8 @@ get_xt_flags(int fd)
 	{
 		if(errno == ERANGE )
 			printf("XT_PAX: corrupted\n");
-
 		if( errno == ENOATTR)
 			printf("XT_PAX: not present\n");
-
 		if(errno == ENOTSUP)
 			printf("XT_PAX: not supported\n");
 	}
@@ -390,7 +388,7 @@ set_pt_flags(int fd, uint16_t pt_flags)
 
 	if((elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL)) == NULL)
 		error(EXIT_FAILURE, 0, "elf_begin() fail: %s", elf_errmsg(elf_errno()));
-	}
+
 	if(elf_kind(elf) != ELF_K_ELF)
 	{
 		elf_end(elf);



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [gentoo-commits] proj/elfix:master commit in: src/, scripts/, /
@ 2012-11-10 18:18 Anthony G. Basile
  0 siblings, 0 replies; 5+ messages in thread
From: Anthony G. Basile @ 2012-11-10 18:18 UTC (permalink / raw
  To: gentoo-commits

commit:     02d7dcc535a2c39492bbfb6b49543fd53bebe05d
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 10 18:16:11 2012 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Nov 10 18:16:11 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=02d7dcc5

Work towards making both PT_PAX and xattr PAX optional

X-Gentoo-Bug: 427890
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=427890
X-Gentoo-Bug: 440018
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=440018

---
 configure.ac        |  108 +++++++++++++++++++++++++++++++++++----------------
 scripts/paxmodule.c |   16 ++++----
 scripts/setup.py    |    8 ++--
 src/paxctl-ng.c     |   24 ++++++------
 4 files changed, 98 insertions(+), 58 deletions(-)

diff --git a/configure.ac b/configure.ac
index 75a09b7..f0299a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,15 +18,79 @@ AC_ARG_ENABLE(
 )
 AM_CONDITIONAL([TEST],[test "x$enable_tests" = "xyes"])
 
+# Checks for programs.
+AC_PROG_AWK
+AC_PROG_CC
+AC_PROG_SED
+
+# Checks for header files.
+AC_CHECK_HEADERS(
+	[errno.h error.h fcntl.h libgen.h stdio.h stdlib.h string.h \
+	sys/mman.h sys/stat.h sys/types.h unistd.h],
+	[],
+	[AC_MSG_ERROR(["Missing necessary header"])]
+)
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_TYPE_UINT8_T
+AC_TYPE_UINT16_T
+
+# Checks for library functions.
+AC_FUNC_ERROR_AT_LINE
+AC_FUNC_FORK
+AC_FUNC_MMAP
+AC_CHECK_FUNCS([memset strerror])
+
+AC_ARG_ENABLE(
+	[ptpax],
+	AS_HELP_STRING(
+		[--enable-ptpax],
+		[enable support for pax markings in PT_PAX ELF phdr]
+	),
+	[
+		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"
+			]
+		)
+	],
+	[
+		CFLAGS+=" -DPTPAX"
+	]
+)
+
 AC_ARG_ENABLE(
-	[xattr],
+	[xtpax],
 	AS_HELP_STRING(
-		[--enable-xattr],
+		[--enable-xtpax],
 		[enable support for pax markings in xattrs]
 	),
 	[
 		AS_IF(
-			[test "x$enable_xattr" = "xyes"],
+			[test "x$enable_xtpax" = "xyes"],
 			[
 				AC_CHECK_HEADERS(
 					[attr/xattr.h],
@@ -39,47 +103,23 @@ AC_ARG_ENABLE(
 					[],
 					[AC_MSG_ERROR(["Missing necessary function fgetxattr in libattr"])]
 				)
-				CFLAGS+=" -DXATTR"
+				CFLAGS+=" -DXTPAX"
 			],
 			[
-				CFLAGS+=" -UXATTR"
+				CFLAGS+=" -UXTPAX"
 			]
 		)
 	],
 	[
-		CFLAGS+=" -DXATTR"
+		CFLAGS+=" -DXTPAX"
 	]
 )
 
-# Checks for programs.
-AC_PROG_AWK
-AC_PROG_CC
-AC_PROG_SED
-
-# Checks for libraries.
-AC_CHECK_LIB([elf], [elf_begin],[],[AC_MSG_ERROR(["Missing necessary function elf_begin in libelf"])])
-
-# Checks for header files.
-
-AC_CHECK_HEADERS(
-	[errno.h error.h fcntl.h gelf.h libgen.h stdio.h stdlib.h string.h \
-	sys/mman.h sys/stat.h sys/types.h unistd.h],
-	[],
-	[AC_MSG_ERROR(["Missing necessary header"])]
-)
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_TYPE_PID_T
-AC_TYPE_SIZE_T
-AC_TYPE_UINT8_T
-AC_TYPE_UINT16_T
-
-# Checks for library functions.
-AC_FUNC_ERROR_AT_LINE
-AC_FUNC_FORK
-AC_FUNC_MMAP
-AC_CHECK_FUNCS([memset strerror])
+if [test "x$enable_ptpax" != "xyes" -a  "x$enable_xtpax" != "xyes" ]; then
+	AC_MSG_ERROR(["You must enable either ptpax or xtpax"])
+fi
 
+# Ready to configure our files
 AC_CONFIG_FILES([
 	Makefile
 	src/Makefile

diff --git a/scripts/paxmodule.c b/scripts/paxmodule.c
index c3dfc28..9cd1ec3 100644
--- a/scripts/paxmodule.c
+++ b/scripts/paxmodule.c
@@ -22,7 +22,7 @@
 
 #include <gelf.h>
 
-#ifdef XATTR
+#ifdef XTPAX
 #include <attr/xattr.h>
 #endif
 
@@ -31,7 +31,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#ifdef XATTR
+#ifdef XTPAX
 #define PAX_NAMESPACE	"user.pax.flags"
 #endif
 
@@ -177,7 +177,7 @@ string2bin(char *buf)
 }
 
 
-#ifdef XATTR
+#ifdef XTPAX
 uint16_t
 get_xt_flags(int fd)
 {
@@ -236,7 +236,7 @@ pax_getflags(PyObject *self, PyObject *args)
 		return NULL;
 	}
 
-#ifdef XATTR
+#ifdef XTPAX
 	flags = get_xt_flags(fd);
 	if( flags != UINT16_MAX )
 	{
@@ -252,7 +252,7 @@ pax_getflags(PyObject *self, PyObject *args)
 			memset(buf, 0, FLAGS_SIZE);
 			bin2string(flags, buf);
 		}
-#ifdef XATTR
+#ifdef XTPAX
 	}
 #endif
 
@@ -316,7 +316,7 @@ set_pt_flags(int fd, uint16_t pt_flags)
 }
 
 
-#ifdef XATTR
+#ifdef XTPAX
 void
 set_xt_flags(int fd, uint16_t xt_flags)
 {
@@ -352,7 +352,7 @@ pax_setbinflags(PyObject *self, PyObject *args)
 
 	set_pt_flags(fd, flags);
 
-#ifdef XATTR
+#ifdef XTPAX
 	set_xt_flags(fd, flags);
 #endif
 
@@ -384,7 +384,7 @@ pax_setstrflags(PyObject *self, PyObject *args)
 
 	set_pt_flags(fd, flags);
 
-#ifdef XATTR
+#ifdef XTPAX
 	set_xt_flags(fd, flags);
 #endif
 

diff --git a/scripts/setup.py b/scripts/setup.py
index 40aecdb..8c78279 100755
--- a/scripts/setup.py
+++ b/scripts/setup.py
@@ -3,26 +3,26 @@
 import os
 from distutils.core import setup, Extension
 
-xattr = os.getenv('XATTR')
+xattr = os.getenv('XTPAX')
 
 if xattr != None:
 	module1 = Extension(
 		name='pax',
 		sources = ['paxmodule.c'],
 		libraries = ['elf', 'attr'],
-		define_macros = [('XATTR', None)]
+		define_macros = [('XTPAX', None)]
 	)
 else:
 	module1 = Extension(
 		name='pax',
 		sources = ['paxmodule.c'],
 		libraries = ['elf'],
-		undef_macros = ['XATTR']
+		undef_macros = ['XTPAX']
 	)
 
 setup(
 	name = 'PaxPython',
-	version = '1.0',
+	version = '2.0',
 	author = 'Anthony G. Basile',
 	author_email = 'blueness@gentoo.org',
 	url = 'http://dev.gentoo.org/~blueness/elfix',

diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c
index 025ea24..b467c2a 100644
--- a/src/paxctl-ng.c
+++ b/src/paxctl-ng.c
@@ -25,7 +25,7 @@
 
 #include <gelf.h>
 
-#ifdef XATTR
+#ifdef XTPAX
 #include <attr/xattr.h>
 #endif
 
@@ -36,7 +36,7 @@
 
 #include <config.h>
 
-#ifdef XATTR
+#ifdef XTPAX
 #define PAX_NAMESPACE	"user.pax.flags"
 
 #define CREATE_XT_FLAGS_SECURE		1
@@ -57,7 +57,7 @@ print_help_exit(char *v)
 		"Program Name : %s\n"
 		"Description  : Get or set pax flags on an ELF object\n\n"
 		"Usage        : %s -PpSsMmEeRrv ELF | -Zv ELF | -zv ELF\n"
-#ifdef XATTR
+#ifdef XTPAX
 		"             : %s -Cv ELF | -cv ELF | -Fv ELF | -fv ELF\n"
 #endif
 		"             : %s -v ELF | -h\n\n"
@@ -67,7 +67,7 @@ print_help_exit(char *v)
 		"             : -E enable EMUTRAMP\t-e disable  EMUTRAMP\n"
 		"             : -R enable RANDMMAP\t-r disable  RANDMMAP\n"
 		"             : -Z most secure settings\t-z all default settings\n"
-#ifdef XATTR
+#ifdef XTPAX
 		"             : -C create XT_PAX with most secure setting\n"
 		"             : -c create XT_PAX all default settings\n"
 		"             : -F copy PT_PAX to XT_PAX\n"
@@ -98,7 +98,7 @@ parse_cmd_args(int argc, char *argv[], uint16_t *pax_flags, int *verbose, int *c
 	*pax_flags = 0;
 	*verbose = 0;
 	*cp_flags = 0; 
-#ifdef XATTR
+#ifdef XTPAX
 	while((oc = getopt(argc, argv,":PpSsMmEeRrZzCcFfvh")) != -1)
 #else
 	while((oc = getopt(argc, argv,":PpSsMmEeRrZzvh")) != -1)
@@ -157,7 +157,7 @@ parse_cmd_args(int argc, char *argv[], uint16_t *pax_flags, int *verbose, int *c
 					PF_RANDMMAP | PF_NORANDMMAP ;
 				solitaire += 1;
 				break;
-#ifdef XATTR
+#ifdef XTPAX
 			case 'C':
 				solitaire += 1;
 				*cp_flags = CREATE_XT_FLAGS_SECURE;
@@ -252,7 +252,7 @@ get_pt_flags(int fd, int verbose)
 }
 
 
-#ifdef XATTR
+#ifdef XTPAX
 uint16_t
 string2bin(char *buf)
 {
@@ -339,7 +339,7 @@ print_flags(int fd, int verbose)
 		printf("\tPT_PAX: %s\n", buf);
 	}
 
-#ifdef XATTR
+#ifdef XTPAX
 	flags = get_xt_flags(fd);
 	if( flags == UINT16_MAX )
 		printf("\tXT_PAX: not found\n");
@@ -505,7 +505,7 @@ set_pt_flags(int fd, uint16_t pt_flags, int verbose)
 }
 
 
-#ifdef XATTR
+#ifdef XTPAX
 void
 set_xt_flags(int fd, uint16_t xt_flags)
 {
@@ -532,7 +532,7 @@ set_flags(int fd, uint16_t *pax_flags, int rdwr_pt_pax, int verbose)
 		set_pt_flags(fd, flags, verbose);
 	}
 
-#ifdef XATTR
+#ifdef XTPAX
 	flags = get_xt_flags(fd);
 	if( flags == UINT16_MAX )
 		flags = PF_NOEMUTRAMP ;
@@ -542,7 +542,7 @@ set_flags(int fd, uint16_t *pax_flags, int rdwr_pt_pax, int verbose)
 }
 
 
-#ifdef XATTR
+#ifdef XTPAX
 void
 create_xt_flags(int fd, int cp_flags)
 {
@@ -609,7 +609,7 @@ main( int argc, char *argv[])
 			}
 		}
 
-#ifdef XATTR
+#ifdef XTPAX
 		if(cp_flags == CREATE_XT_FLAGS_SECURE || cp_flags == CREATE_XT_FLAGS_DEFAULT)
 			create_xt_flags(fd, cp_flags);
 


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [gentoo-commits] proj/elfix:master commit in: src/, scripts/, /
@ 2012-12-12 19:58 Anthony G. Basile
  0 siblings, 0 replies; 5+ messages in thread
From: Anthony G. Basile @ 2012-12-12 19:58 UTC (permalink / raw
  To: gentoo-commits

commit:     382afaee42d294e84e45318790de6593b5b39219
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 12 19:50:12 2012 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Wed Dec 12 19:57:46 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=382afaee

Add logic for NEED_PAX_DECLS when gelf.h is present but lacks them

On a gentoo system <sys-libs/glibc-2.16, elf.h is no longer patched
to provide PT_PAX_FLAGS and PF_* for the PAX program header of ELF
binaries.  As a result, we must include them.  These will eventuall
be exported by upstream PAX team in a separate header but for now
we test 1) do we want PT_PAX, if yes, then test for gelf.h and for
the DECLS.  If we don't have the DECLS, then include our local copy.
or 2) so we want only XATTR PAX, in which case don't test for gelf.h,
don't include it and provide our local DECLS.

---
 configure.ac        |    6 ++-
 scripts/paxmodule.c |    7 +++-
 scripts/setup.py    |   89 ++++++++++++++++++++++++++++++++++++++++-----------
 src/paxctl-ng.c     |    7 +++-
 4 files changed, 86 insertions(+), 23 deletions(-)

diff --git a/configure.ac b/configure.ac
index 43c74e9..7c7e3f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,13 +66,15 @@ AS_IF(
 		AC_CHECK_DECLS(
 			[PT_PAX_FLAGS, PF_PAGEEXEC, PF_MPROTECT, PF_RANDMMAP],
 			[],
-			[AC_MSG_ERROR(["Missing necessary define's in gelf.h"])],
+			[
+				CFLAGS+=" -DNEED_PAX_DECLS"
+			],
 			[[#include <gelf.h>]]
 		)
 		CFLAGS+=" -DPTPAX"
 	],
 	[
-		CFLAGS+=" -UPTPAX"
+		CFLAGS+=" -UPTPAX -DNEED_PAX_DECLS"
 	]
 )
 

diff --git a/scripts/paxmodule.c b/scripts/paxmodule.c
index 56cef3a..8ae10be 100644
--- a/scripts/paxmodule.c
+++ b/scripts/paxmodule.c
@@ -26,13 +26,18 @@
 
 #ifdef PTPAX
  #include <gelf.h>
-#else
+#endif
+
+#ifdef NEED_PAX_DECLS
+ #define PT_PAX_FLAGS    0x65041580      /* Indicates PaX flag markings */
  #define PF_PAGEEXEC     (1 << 4)        /* Enable  PAGEEXEC */
  #define PF_NOPAGEEXEC   (1 << 5)        /* Disable PAGEEXEC */
  #define PF_SEGMEXEC     (1 << 6)        /* Enable  SEGMEXEC */
  #define PF_NOSEGMEXEC   (1 << 7)        /* Disable SEGMEXEC */
  #define PF_MPROTECT     (1 << 8)        /* Enable  MPROTECT */
  #define PF_NOMPROTECT   (1 << 9)        /* Disable MPROTECT */
+ #define PF_RANDEXEC     (1 << 10)       /* DEPRECATED: Enable  RANDEXEC */
+ #define PF_NORANDEXEC   (1 << 11)       /* DEPRECATED: Disable RANDEXEC */
  #define PF_EMUTRAMP     (1 << 12)       /* Enable  EMUTRAMP */
  #define PF_NOEMUTRAMP   (1 << 13)       /* Disable EMUTRAMP */
  #define PF_RANDMMAP     (1 << 14)       /* Enable  RANDMMAP */

diff --git a/scripts/setup.py b/scripts/setup.py
index 528cfa0..0c6e9cc 100755
--- a/scripts/setup.py
+++ b/scripts/setup.py
@@ -1,40 +1,91 @@
 #!/usr/bin/env python
 
-import os
+import sys, os, re
 from distutils.core import setup, Extension
 
 ptpax = os.getenv('PTPAX')
 xtpax = os.getenv('XTPAX')
 
-if ptpax != None and xtpax == None:
-	module1 = Extension(
-		name='pax',
-		sources = ['paxmodule.c'],
-		libraries = ['elf'],
-		undef_macros = ['XTPAX'],
-		define_macros = [('PTPAX', 1)]
-	)
+# This is a bit hacky since we include gelf.h but
+# the pax decls are in elf.h.  The stacking goes as
+#	gelf.h
+#		libelf.h
+#			elf.h
+
 
-elif ptpax == None and xtpax != None:
+# we want only XTPAX and so NEED_PAX_DECLS
+if ptpax == None and xtpax != None:
 	module1 = Extension(
 		name='pax',
 		sources = ['paxmodule.c'],
 		libraries = ['attr'],
 		undef_macros = ['PTPAX'],
-		define_macros = [('PTPAX', 1)]
+		define_macros = [('XTPAX', 1), ('NEED_PAX_DECLS', 1)]
 	)
 
-if ptpax != None and xtpax != None:
-	module1 = Extension(
-		name='pax',
-		sources = ['paxmodule.c'],
-		libraries = ['elf', 'attr'],
-		define_macros = [('PTPAX', 1), ('XTPAX', 1)]
-	)
+# We want PTPAX but don't know if we NEED_PAX_DECLS
+else:
+	try:
+		need_pax_decls = True
+		f = open('/usr/include/elf.h', 'r')
+		for line in f.readlines():
+			if re.search('PF_PAGEEXEC', line):
+				need_pax_decls = False
+		f.close()
+
+	except IOError as e:
+		print("Can't find elf.h in the usual place!")
+		sys.exit(1)
+
+	# We NEED_PAX_DECLS
+	if need_pax_decls:
+
+		# We want PTPAX but not XTPAX
+		if ptpax != None and xtpax == None:
+			module1 = Extension(
+				name='pax',
+				sources = ['paxmodule.c'],
+				libraries = ['elf'],
+				undef_macros = ['XTPAX'],
+				define_macros = [('PTPAX', 1), ('NEED_PAX_DECLS', 1)]
+			)
+
+		# We want both PTAPX and XTPAX
+		elif ptpax != None and xtpax != None:
+			module1 = Extension(
+				name='pax',
+				sources = ['paxmodule.c'],
+				libraries = ['elf', 'attr'],
+				define_macros = [('PTPAX', 1), ('XTPAX', 1), ('NEED_PAX_DECLS', 1)]
+			)
+
+	# We don't NEED_PAX_DECLS
+	else:
+
+		# We want both PTAPX and XTPAX
+		if ptpax != None and xtpax == None:
+			module1 = Extension(
+				name='pax',
+				sources = ['paxmodule.c'],
+				libraries = ['elf'],
+				undef_macros = ['XTPAX', 'NEED_PAX_DECLS'],
+				define_macros = [('PTPAX', 1)]
+			)
+
+		# We want both PTAPX and XTPAX
+		elif ptpax != None and xtpax != None:
+			module1 = Extension(
+				name='pax',
+				sources = ['paxmodule.c'],
+				libraries = ['elf', 'attr'],
+				undef_macros = ['NEED_PAX_DECLS'],
+				define_macros = [('PTPAX', 1), ('XTPAX', 1)]
+			)
+
 
 setup(
 	name = 'PaxPython',
-	version = '2.0',
+	version = '0.6.1',
 	author = 'Anthony G. Basile',
 	author_email = 'blueness@gentoo.org',
 	url = 'http://dev.gentoo.org/~blueness/elfix',

diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c
index e58cebb..d5acaf8 100644
--- a/src/paxctl-ng.c
+++ b/src/paxctl-ng.c
@@ -29,13 +29,18 @@
 
 #ifdef PTPAX
  #include <gelf.h>
-#else
+#endif
+
+#ifdef NEED_PAX_DECLS
+ #define PT_PAX_FLAGS    0x65041580      /* Indicates PaX flag markings */
  #define PF_PAGEEXEC     (1 << 4)        /* Enable  PAGEEXEC */
  #define PF_NOPAGEEXEC   (1 << 5)        /* Disable PAGEEXEC */
  #define PF_SEGMEXEC     (1 << 6)        /* Enable  SEGMEXEC */
  #define PF_NOSEGMEXEC   (1 << 7)        /* Disable SEGMEXEC */
  #define PF_MPROTECT     (1 << 8)        /* Enable  MPROTECT */
  #define PF_NOMPROTECT   (1 << 9)        /* Disable MPROTECT */
+ #define PF_RANDEXEC     (1 << 10)       /* DEPRECATED: Enable  RANDEXEC */
+ #define PF_NORANDEXEC   (1 << 11)       /* DEPRECATED: Disable RANDEXEC */
  #define PF_EMUTRAMP     (1 << 12)       /* Enable  EMUTRAMP */
  #define PF_NOEMUTRAMP   (1 << 13)       /* Disable EMUTRAMP */
  #define PF_RANDMMAP     (1 << 14)       /* Enable  RANDMMAP */


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [gentoo-commits] proj/elfix:master commit in: src/, scripts/, /
@ 2018-11-28 21:34 Anthony G. Basile
  0 siblings, 0 replies; 5+ messages in thread
From: Anthony G. Basile @ 2018-11-28 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     abeac3adcbfa4b853b9a7d727f5c6b134fad6fe5
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Tue May 15 07:33:40 2018 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Wed Nov 28 21:33:12 2018 +0000
URL:        https://gitweb.gentoo.org/proj/elfix.git/commit/?id=abeac3ad

attr/xattr.h is deprecated. Use sys/xattr.h instead

Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>

 configure.ac        | 4 ++--
 scripts/paxmodule.c | 2 +-
 src/paxctl-ng.c     | 5 ++++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 208d566..84ef48d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,9 +114,9 @@ AS_IF(
     [test "x$enable_xtpax" != "xno"],
     [
         AC_CHECK_HEADERS(
-            [attr/xattr.h],
+            [sys/xattr.h],
             [],
-            [AC_MSG_ERROR(["Missing necessary attr/xattr.h"])]
+            [AC_MSG_ERROR(["Missing necessary sys/xattr.h"])]
         )
         AC_CHECK_LIB(
             [attr],

diff --git a/scripts/paxmodule.c b/scripts/paxmodule.c
index 1355f86..6a93420 100644
--- a/scripts/paxmodule.c
+++ b/scripts/paxmodule.c
@@ -45,7 +45,7 @@
 #endif
 
 #ifdef XTPAX
- #include <attr/xattr.h>
+ #include <sys/xattr.h>
  #define PAX_NAMESPACE	"user.pax.flags"
 #endif
 

diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c
index d340a43..25396d4 100644
--- a/src/paxctl-ng.c
+++ b/src/paxctl-ng.c
@@ -49,7 +49,10 @@
 #endif
 
 #ifdef XTPAX
- #include <attr/xattr.h>
+ #include <sys/xattr.h>
+ #ifndef ENOATTR
+  #define ENOATTR ENODATA
+ #endif
  #define PAX_NAMESPACE	"user.pax.flags"
  #define CREATE_XT_FLAGS_SECURE         1
  #define CREATE_XT_FLAGS_DEFAULT        2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-11-28 21:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-08 18:13 [gentoo-commits] proj/elfix:master commit in: src/, scripts/, / Anthony G. Basile
  -- strict thread matches above, loose matches on Subject: below --
2011-10-20 19:03 Anthony G. Basile
2012-11-10 18:18 Anthony G. Basile
2012-12-12 19:58 Anthony G. Basile
2018-11-28 21:34 Anthony G. Basile

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox