aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2012-12-13 21:16:06 -0500
committerAnthony G. Basile <blueness@gentoo.org>2012-12-13 21:19:41 -0500
commit73a50ec221d5152722e95fc8e46900605554e64d (patch)
tree704616e6b053372b2f69833da9ca36c48117253b /scripts
parentscripts/paxmodule.c: adopt the update_flags() logic of paxctl-ng.c (diff)
downloadelfix-73a50ec221d5152722e95fc8e46900605554e64d.tar.gz
elfix-73a50ec221d5152722e95fc8e46900605554e64d.tar.bz2
elfix-73a50ec221d5152722e95fc8e46900605554e64d.zip
scripts/paxmodule.c: adopt the parse_cmd_args() logic of paxctl-ng.c
Diffstat (limited to 'scripts')
-rw-r--r--scripts/paxmodule.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/scripts/paxmodule.c b/scripts/paxmodule.c
index 40450ac..57c9ce1 100644
--- a/scripts/paxmodule.c
+++ b/scripts/paxmodule.c
@@ -538,6 +538,55 @@ pax_setbinflags(PyObject *self, PyObject *args)
return Py_BuildValue("");
}
+
+//This logic is like parse_cmd_args() in paxctl-ng.c
+uint16_t
+parse_sflags(char *sflags)
+{
+ int i;
+ uint16_t flags = 0;
+
+ for(i = 0; i < strlen(sflags); i++)
+ {
+ switch(sflags[i])
+ {
+ case 'P':
+ flags |= PF_PAGEEXEC;
+ break;
+ case 'p':
+ flags |= PF_NOPAGEEXEC;
+ break ;
+ case 'E':
+ flags |= PF_EMUTRAMP;
+ break;
+ case 'e':
+ flags |= PF_NOEMUTRAMP;
+ break ;
+ case 'M':
+ flags |= PF_MPROTECT;
+ break;
+ case 'm':
+ flags |= PF_NOMPROTECT;
+ break ;
+ case 'R':
+ flags |= PF_RANDMMAP;
+ break;
+ case 'r':
+ flags |= PF_NORANDMMAP;
+ break ;
+ case 'S':
+ flags |= PF_SEGMEXEC;
+ break;
+ case 's':
+ flags |= PF_NOSEGMEXEC;
+ break ;
+ }
+ }
+
+ return flags;
+}
+
+
static PyObject *
pax_setstrflags(PyObject *self, PyObject *args)
{
@@ -563,7 +612,7 @@ pax_setstrflags(PyObject *self, PyObject *args)
}
}
- flags = string2bin(sflags);
+ flags = parse_sflags(sflags);
#ifdef PTPAX
if(rdwr_pt_pax)