aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac108
-rw-r--r--scripts/paxmodule.c16
-rwxr-xr-xscripts/setup.py8
-rw-r--r--src/paxctl-ng.c24
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);