- Add python bindings for sesearch and seinfo

This commit is contained in:
Daniel J Walsh 2009-08-11 21:36:40 +00:00
parent 766fa2156a
commit d7380e7a75
1 changed files with 78 additions and 42 deletions

View File

@ -1,6 +1,6 @@
diff -up setools-3.3.6/configure.ac.python setools-3.3.6/configure.ac
--- setools-3.3.6/configure.ac.python 2009-08-10 15:24:55.000000000 -0400
+++ setools-3.3.6/configure.ac 2009-08-10 15:24:59.000000000 -0400
--- setools-3.3.6/configure.ac.python 2009-07-22 14:07:35.000000000 -0400
+++ setools-3.3.6/configure.ac 2009-08-11 13:15:57.000000000 -0400
@@ -216,6 +216,9 @@ if test "x${enable_jswig}" = xyes; then
do_swigify_java=yes
do_swigify=yes
@ -29,8 +29,8 @@ diff -up setools-3.3.6/configure.ac.python setools-3.3.6/configure.ac
packages/libqpol.pc packages/libapol.pc packages/libpoldiff.pc packages/libseaudit.pc packages/libsefs.pc])
diff -up setools-3.3.6/Makefile.am.python setools-3.3.6/Makefile.am
--- setools-3.3.6/Makefile.am.python 2009-08-10 15:23:45.000000000 -0400
+++ setools-3.3.6/Makefile.am 2009-08-10 15:23:50.000000000 -0400
--- setools-3.3.6/Makefile.am.python 2008-02-22 14:06:28.000000000 -0500
+++ setools-3.3.6/Makefile.am 2009-08-11 13:15:57.000000000 -0400
@@ -10,7 +10,7 @@ if BUILD_GUI
endif
# sediffx is also built conditionally, from sediffx/Makefile.am
@ -41,8 +41,8 @@ diff -up setools-3.3.6/Makefile.am.python setools-3.3.6/Makefile.am
#old indent opts
#INDENT_OPTS = -npro -nbad -bap -sob -ss -l132 -di1 -nbc -br -nbbb -c40 -cd40 -ncdb -ce -cli0 -cp40 -ncs -d0 -nfc1 -nfca -i8 -ts8 -ci8 -lp -ip0 -npcs -npsl -sc
diff -up setools-3.3.6/Makefile.in.python setools-3.3.6/Makefile.in
--- setools-3.3.6/Makefile.in.python 2009-08-10 15:24:17.000000000 -0400
+++ setools-3.3.6/Makefile.in 2009-08-10 15:25:59.000000000 -0400
--- setools-3.3.6/Makefile.in.python 2009-07-22 14:08:36.000000000 -0400
+++ setools-3.3.6/Makefile.in 2009-08-11 15:14:56.000000000 -0400
@@ -79,7 +79,7 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGE
ETAGS = etags
CTAGS = ctags
@ -61,15 +61,14 @@ diff -up setools-3.3.6/Makefile.in.python setools-3.3.6/Makefile.in
#old indent opts
#INDENT_OPTS = -npro -nbad -bap -sob -ss -l132 -di1 -nbc -br -nbbb -c40 -cd40 -ncdb -ce -cli0 -cp40 -ncs -d0 -nfc1 -nfca -i8 -ts8 -ci8 -lp -ip0 -npcs -npsl -sc
diff -up setools-3.3.6/python/Makefile.am.python setools-3.3.6/python/Makefile.am
--- setools-3.3.6/python/Makefile.am.python 2009-08-11 09:57:16.000000000 -0400
+++ setools-3.3.6/python/Makefile.am 2009-08-10 15:23:25.000000000 -0400
@@ -0,0 +1,2 @@
diff -up /dev/null setools-3.3.6/python/Makefile.am
--- /dev/null 2009-08-08 15:30:39.325298375 -0400
+++ setools-3.3.6/python/Makefile.am 2009-08-11 15:12:36.000000000 -0400
@@ -0,0 +1 @@
+SUBDIRS = setools
+
diff -up setools-3.3.6/python/Makefile.in.python setools-3.3.6/python/Makefile.in
--- setools-3.3.6/python/Makefile.in.python 2009-08-11 09:57:20.000000000 -0400
+++ setools-3.3.6/python/Makefile.in 2009-08-10 15:25:58.000000000 -0400
diff -up /dev/null setools-3.3.6/python/Makefile.in
--- /dev/null 2009-08-08 15:30:39.325298375 -0400
+++ setools-3.3.6/python/Makefile.in 2009-08-11 15:14:56.000000000 -0400
@@ -0,0 +1,715 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
@ -786,9 +785,9 @@ diff -up setools-3.3.6/python/Makefile.in.python setools-3.3.6/python/Makefile.i
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff -up setools-3.3.6/python/setools/__init__.py.python setools-3.3.6/python/setools/__init__.py
--- setools-3.3.6/python/setools/__init__.py.python 2009-08-11 09:56:37.000000000 -0400
+++ setools-3.3.6/python/setools/__init__.py 2009-08-10 17:28:48.000000000 -0400
diff -up /dev/null setools-3.3.6/python/setools/__init__.py
--- /dev/null 2009-08-08 15:30:39.325298375 -0400
+++ setools-3.3.6/python/setools/__init__.py 2009-08-11 13:15:57.000000000 -0400
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+
@ -839,10 +838,10 @@ diff -up setools-3.3.6/python/setools/__init__.py.python setools-3.3.6/python/se
+def seinfo(setype, name=None):
+ dict_list = _seinfo.seinfo(setype, name)
+ return dict_list
diff -up setools-3.3.6/python/setools/Makefile.am.python setools-3.3.6/python/setools/Makefile.am
--- setools-3.3.6/python/setools/Makefile.am.python 2009-08-11 09:56:25.000000000 -0400
+++ setools-3.3.6/python/setools/Makefile.am 2009-08-10 15:23:25.000000000 -0400
@@ -0,0 +1,24 @@
diff -up /dev/null setools-3.3.6/python/setools/Makefile.am
--- /dev/null 2009-08-08 15:30:39.325298375 -0400
+++ setools-3.3.6/python/setools/Makefile.am 2009-08-11 17:17:15.000000000 -0400
@@ -0,0 +1,36 @@
+EXTRA_DIST = \
+ sesearch.c \
+ seinfo.c \
@ -850,12 +849,24 @@ diff -up setools-3.3.6/python/setools/Makefile.am.python setools-3.3.6/python/se
+ setup.py \
+ $(NULL)
+
+AM_CFLAGS = @DEBUGCFLAGS@ @WARNCFLAGS@ @PROFILECFLAGS@ @SELINUX_CFLAGS@ \
+ @QPOL_CFLAGS@ @APOL_CFLAGS@
+AM_CXXFLAGS = @DEBUGCXXFLAGS@ @WARNCXXFLAGS@ @PROFILECFLAGS@ @SELINUX_CFLAGS@ \
+ @QPOL_CFLAGS@ @APOL_CFLAGS@ @SEFS_CFLAGS@
+AM_LDFLAGS = @DEBUGLDFLAGS@ @WARNLDFLAGS@ @PROFILELDFLAGS@
+
+LDADD = @SELINUX_LIB_FLAG@ @APOL_LIB_FLAG@ @QPOL_LIB_FLAG@
+DEPENDENCIES = $(top_builddir)/libapol/src/libapol.so $(top_builddir)/libqpol/src/libqpol.so
+all-am: python-build
+
+seinfo_SOURCES = seinfo.c
+
+sesearch_SOURCES = sesearch.c
+
+python-build: sesearch.c seinfo.c
+ @mkdir -p setools
+ @cp __init__.py setools
+ $(PYTHON) setup.py build
+ LIBS="$(QPOL_LIB_FLAG) $(APOL_LIB_FLAG)" INCLUDES="$(QPOL_CFLAGS) $(APOL_CFLAGS)" $(PYTHON) setup.py build
+
+install-exec-hook:
+ $(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
@ -867,10 +878,10 @@ diff -up setools-3.3.6/python/setools/Makefile.am.python setools-3.3.6/python/se
+ $(PYTHON) setup.py clean -a
+ rm -f *~
+
diff -up setools-3.3.6/python/setools/Makefile.in.python setools-3.3.6/python/setools/Makefile.in
--- setools-3.3.6/python/setools/Makefile.in.python 2009-08-11 09:56:30.000000000 -0400
+++ setools-3.3.6/python/setools/Makefile.in 2009-08-10 15:25:58.000000000 -0400
@@ -0,0 +1,539 @@
diff -up /dev/null setools-3.3.6/python/setools/Makefile.in
--- /dev/null 2009-08-08 15:30:39.325298375 -0400
+++ setools-3.3.6/python/setools/Makefile.in 2009-08-11 17:17:18.000000000 -0400
@@ -0,0 +1,549 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
@ -1202,6 +1213,17 @@ diff -up setools-3.3.6/python/setools/Makefile.in.python setools-3.3.6/python/se
+ setup.py \
+ $(NULL)
+
+AM_CFLAGS = @DEBUGCFLAGS@ @WARNCFLAGS@ @PROFILECFLAGS@ @SELINUX_CFLAGS@ \
+ @QPOL_CFLAGS@ @APOL_CFLAGS@
+
+AM_CXXFLAGS = @DEBUGCXXFLAGS@ @WARNCXXFLAGS@ @PROFILECFLAGS@ @SELINUX_CFLAGS@ \
+ @QPOL_CFLAGS@ @APOL_CFLAGS@ @SEFS_CFLAGS@
+
+AM_LDFLAGS = @DEBUGLDFLAGS@ @WARNLDFLAGS@ @PROFILELDFLAGS@
+LDADD = @SELINUX_LIB_FLAG@ @APOL_LIB_FLAG@ @QPOL_LIB_FLAG@
+DEPENDENCIES = $(top_builddir)/libapol/src/libapol.so $(top_builddir)/libqpol/src/libqpol.so
+seinfo_SOURCES = seinfo.c
+sesearch_SOURCES = sesearch.c
+all: all-am
+
+.SUFFIXES:
@ -1389,13 +1411,12 @@ diff -up setools-3.3.6/python/setools/Makefile.in.python setools-3.3.6/python/se
+ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+ ps ps-am uninstall uninstall-am uninstall-hook
+
+
+all-am: python-build
+
+python-build: sesearch.c seinfo.c
+ @mkdir -p setools
+ @cp __init__.py setools
+ $(PYTHON) setup.py build
+ LIBS="$(QPOL_LIB_FLAG) $(APOL_LIB_FLAG)" INCLUDES="$(QPOL_CFLAGS) $(APOL_CFLAGS)" $(PYTHON) setup.py build
+
+install-exec-hook:
+ $(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
@ -1410,9 +1431,9 @@ diff -up setools-3.3.6/python/setools/Makefile.in.python setools-3.3.6/python/se
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff -up setools-3.3.6/python/setools/seinfo.c.python setools-3.3.6/python/setools/seinfo.c
--- setools-3.3.6/python/setools/seinfo.c.python 2009-08-11 09:56:01.000000000 -0400
+++ setools-3.3.6/python/setools/seinfo.c 2009-08-11 09:45:32.000000000 -0400
diff -up /dev/null setools-3.3.6/python/setools/seinfo.c
--- /dev/null 2009-08-08 15:30:39.325298375 -0400
+++ setools-3.3.6/python/setools/seinfo.c 2009-08-11 16:31:05.000000000 -0400
@@ -0,0 +1,649 @@
+/**
+ * @file
@ -2063,9 +2084,9 @@ diff -up setools-3.3.6/python/setools/seinfo.c.python setools-3.3.6/python/setoo
+ PyModule_AddIntConstant(m, "TYPE", TYPE);
+ PyModule_AddIntConstant(m, "USER", USER);
+}
diff -up setools-3.3.6/python/setools/sesearch.c.python setools-3.3.6/python/setools/sesearch.c
--- setools-3.3.6/python/setools/sesearch.c.python 2009-08-11 09:56:08.000000000 -0400
+++ setools-3.3.6/python/setools/sesearch.c 2009-08-11 09:46:26.000000000 -0400
diff -up /dev/null setools-3.3.6/python/setools/sesearch.c
--- /dev/null 2009-08-08 15:30:39.325298375 -0400
+++ setools-3.3.6/python/setools/sesearch.c 2009-08-11 16:31:05.000000000 -0400
@@ -0,0 +1,477 @@
+// Author: Thomas Liu <tliu@redhat.com>
+
@ -2544,17 +2565,32 @@ diff -up setools-3.3.6/python/setools/sesearch.c.python setools-3.3.6/python/set
+ PyObject *m;
+ m = Py_InitModule("_sesearch", methods);
+}
diff -up setools-3.3.6/python/setools/setup.py.python setools-3.3.6/python/setools/setup.py
--- setools-3.3.6/python/setools/setup.py.python 2009-08-11 09:56:15.000000000 -0400
+++ setools-3.3.6/python/setools/setup.py 2009-08-10 15:23:25.000000000 -0400
@@ -0,0 +1,10 @@
diff -up /dev/null setools-3.3.6/python/setools/setup.py
--- /dev/null 2009-08-08 15:30:39.325298375 -0400
+++ setools-3.3.6/python/setools/setup.py 2009-08-11 17:29:42.000000000 -0400
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+# Author: Thomas Liu <tliu@redhat.com>
+
+import os
+from distutils.core import setup, Extension
+extension_sesearch = Extension("setools._sesearch", [ "sesearch.c"], libraries=["apol", "qpol"] )
+extension_seinfo = Extension("setools._seinfo", [ "seinfo.c"], libraries=["apol", "qpol"] )
+LIBS=["apol", "qpol"]
+
+try:
+ inc=os.getenv("INCLUDES").split(" ")
+ INCLUDES=map(lambda x: x[2:], inc)
+ LIBDIRS=map(lambda x: "/".join(x.split("/")[:-1]), os.getenv("LIBS").split())
+except:
+ INCLUDES=""
+ LIBDIRS=""
+
+extension_sesearch = Extension("setools._sesearch", [ "sesearch.c"])
+extension_sesearch.include_dirs=INCLUDES
+extension_sesearch.libraries=LIBS
+extension_sesearch.library_dirs=LIBDIRS
+extension_seinfo = Extension("setools._seinfo", [ "seinfo.c"])
+extension_seinfo.include_dirs=INCLUDES
+extension_seinfo.libraries=LIBS
+extension_seinfo.library_dirs=LIBDIRS
+
+setup(name = "setools", version="1.0", description="Python setools bindings", author="Thomas Liu", author_email="tliu@redhat.com", ext_modules=[extension_sesearch, extension_seinfo], packages=["setools"])
+