diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2011-10-05 23:13:28 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2011-10-08 14:53:27 -0400 |
commit | 52380bd399798c63b9a4093072987bc64d417940 (patch) | |
tree | 793007bcfca859d9927cb0a9df850eb6ab96f7f6 | |
parent | scripts/revdep-pax: python rewrite of revdep-paxmark (diff) | |
download | elfix-52380bd399798c63b9a4093072987bc64d417940.tar.gz elfix-52380bd399798c63b9a4093072987bc64d417940.tar.bz2 elfix-52380bd399798c63b9a4093072987bc64d417940.zip |
scripts/paxmodule.c: stub python binding for paxctl
-rw-r--r-- | scripts/paxmodule.c | 47 | ||||
-rwxr-xr-x | scripts/revdep-pax | 3 | ||||
-rwxr-xr-x | scripts/setup.py | 19 |
3 files changed, 69 insertions, 0 deletions
diff --git a/scripts/paxmodule.c b/scripts/paxmodule.c new file mode 100644 index 0000000..03ba794 --- /dev/null +++ b/scripts/paxmodule.c @@ -0,0 +1,47 @@ +#include <Python.h> + +static PyObject * pax_getflags(PyObject *, PyObject *); + +static PyMethodDef PaxMethods[] = { + {"getflags", pax_getflags, METH_VARARGS, "Get the pax flags."}, + {NULL, NULL, 0, NULL} +}; + +static PyObject *PaxError; + +PyMODINIT_FUNC +initpax(void) +{ + PyObject *m; + + m = Py_InitModule("pax", PaxMethods); + if (m == NULL) + return; + + PaxError = PyErr_NewException("pax.error", NULL, NULL); + Py_INCREF(PaxError); + PyModule_AddObject(m, "error", PaxError); +} + + +static PyObject * +pax_getflags(PyObject *self, PyObject *args) +{ + const char *value; + int sts; + + if (!PyArg_ParseTuple(args, "s", &value)) + return NULL; + + printf("%s\n", value); + + sts = 1; + + if (sts < 0) + { + PyErr_SetString(PaxError, "pax_getflags failed"); + return NULL; + } + + return Py_BuildValue("i", sts); +} diff --git a/scripts/revdep-pax b/scripts/revdep-pax index 75e833a..ac21bae 100755 --- a/scripts/revdep-pax +++ b/scripts/revdep-pax @@ -4,6 +4,8 @@ from os import listdir #from os import path import re +import pax + var_db_pkg = '/var/db/pkg' binaries = {} @@ -21,6 +23,7 @@ for cat in listdir(var_db_pkg): binary = linking[0] print binary library_list = re.split(',', linking[1]) + print "\t%s" % library_list binaries[binary] = library_list except: break diff --git a/scripts/setup.py b/scripts/setup.py new file mode 100755 index 0000000..317efbd --- /dev/null +++ b/scripts/setup.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +from distutils.core import setup, Extension + +module1 = Extension( + name='pax', + sources = ['paxmodule.c'] +) + +setup( + name = 'PaxPython', + version = '1.0', + author = 'Anthony G. Basile', + author_email = 'blueness@gentoo.org', + url = 'http://dev.gentoo.org/~blueness/elfix', + description = 'This is bindings between paxctl and python', + license = 'GPL-2', + ext_modules = [module1] +) |