summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXin Ouyang <Xin.Ouyang@windriver.com>2012-03-08 10:35:55 +0800
committerXin Ouyang <Xin.Ouyang@windriver.com>2012-03-08 10:35:55 +0800
commit16ed487d5851566a57996215dccec69412eaad45 (patch)
tree3e79c11e282582beef26cca6262220a3bd49e3d3
parent208e905d1cd122cad54e1301403c985ce5e5a0da (diff)
downloadmeta-selinux-16ed487d5851566a57996215dccec69412eaad45.tar.gz
setools: Add version 3.3.7.
-rw-r--r--recipes-security/setools/setools/setools-Add-seinfo-and-sesearch-python-bindings.patch2775
-rw-r--r--recipes-security/setools/setools/setools-Changes-to-support-named-file_trans-rules.patch1511
-rw-r--r--recipes-security/setools/setools/setools-Don-t-build-python-bindings-if-disabled.patch29
-rw-r--r--recipes-security/setools/setools/setools-Don-t-check-selinux-policies-if-disabled.patch25
-rw-r--r--recipes-security/setools/setools/setools-Fix-man-pages-and-getoptions.patch80
-rw-r--r--recipes-security/setools/setools/setools-Fix-output-to-match-policy-lines.patch36
-rw-r--r--recipes-security/setools/setools/setools-Fix-python-setools-Makefile.am-for-cross.patch33
-rw-r--r--recipes-security/setools/setools/setools-Fix-sepol-calls-to-work-with-latest-libsepol.patch36
-rw-r--r--recipes-security/setools/setools/setools-Fix-test-bug-for-unary-operator.patch25
-rw-r--r--recipes-security/setools/setools/setools-Remove-unused-variables.patch279
-rw-r--r--recipes-security/setools/setools/setools-configure-ac.patch107
-rw-r--r--recipes-security/setools/setools/setools-configure-with-latest-libsepol.patch33
-rw-r--r--recipes-security/setools/setools/setools-cross-ar.patch17
-rw-r--r--recipes-security/setools/setools/setools-seinfo-should-exit-with-correct-errno.patch134
-rw-r--r--recipes-security/setools/setools/setools.pam4
-rw-r--r--recipes-security/setools/setools_3.3.7.bb57
16 files changed, 5181 insertions, 0 deletions
diff --git a/recipes-security/setools/setools/setools-Add-seinfo-and-sesearch-python-bindings.patch b/recipes-security/setools/setools/setools-Add-seinfo-and-sesearch-python-bindings.patch
new file mode 100644
index 0000000..5a37c64
--- /dev/null
+++ b/recipes-security/setools/setools/setools-Add-seinfo-and-sesearch-python-bindings.patch
@@ -0,0 +1,2775 @@
1From 41602f02ffa15d55f6ec8d6cc22ca9c945bfad1f Mon Sep 17 00:00:00 2001
2From: Xin Ouyang <Xin.Ouyang@windriver.com>
3Date: Wed, 7 Mar 2012 10:44:44 +0800
4Subject: [PATCH 1/7] setools: Add seinfo and sesearch python bindings.
5
6Integrated from Fedora:
7https://community.dev.fedoraproject.org/packages/setools/sources/patches/
8---
9 Makefile.am | 2 +-
10 configure.ac | 14 +-
11 python/Makefile.am | 1 +
12 python/Makefile.in | 716 +++++++++++++++++++++++++++++++++++++++++
13 python/setools/Makefile.am | 36 ++
14 python/setools/Makefile.in | 550 +++++++++++++++++++++++++++++++
15 python/setools/__init__.py | 50 +++
16 python/setools/seinfo.c | 769 ++++++++++++++++++++++++++++++++++++++++++++
17 python/setools/sesearch.c | 478 +++++++++++++++++++++++++++
18 python/setools/setup.py | 25 ++
19 10 files changed, 2635 insertions(+), 6 deletions(-)
20 create mode 100644 python/Makefile.am
21 create mode 100644 python/Makefile.in
22 create mode 100644 python/setools/Makefile.am
23 create mode 100644 python/setools/Makefile.in
24 create mode 100644 python/setools/__init__.py
25 create mode 100644 python/setools/seinfo.c
26 create mode 100644 python/setools/sesearch.c
27 create mode 100644 python/setools/setup.py
28
29diff --git a/Makefile.am b/Makefile.am
30index 5dc1b5d..176c8ea 100644
31--- a/Makefile.am
32+++ b/Makefile.am
33@@ -10,7 +10,7 @@ if BUILD_GUI
34 endif
35 # sediffx is also built conditionally, from sediffx/Makefile.am
36
37-SUBDIRS = libqpol libapol libsefs libpoldiff libseaudit secmds sechecker sediff man packages debian $(MAYBE_APOL) $(MAYBE_GUI)
38+SUBDIRS = libqpol libapol libsefs libpoldiff libseaudit secmds sechecker sediff man packages debian $(MAYBE_APOL) $(MAYBE_GUI) python
39
40 #old indent opts
41 #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
42diff --git a/configure.ac b/configure.ac
43index b885981..e837e03 100644
44--- a/configure.ac
45+++ b/configure.ac
46@@ -194,7 +194,7 @@ AC_ARG_ENABLE(swig-java,
47 enable_jswig="$enableval")
48 if test "x${enable_jswig}" = xyes; then
49 if test ${do_swigify} = no; then
50- AC_PROG_SWIG(1.3.28)
51+ AC_PROG_SWIG(2.0.0)
52 fi
53 AC_JAVA_OPTIONS
54 if test "x$JAVAPREFIX" = x; then
55@@ -216,21 +216,23 @@ if test "x${enable_jswig}" = xyes; then
56 do_swigify_java=yes
57 do_swigify=yes
58 fi
59+
60+AM_PATH_PYTHON(2.7)
61+
62 AC_ARG_ENABLE(swig-python,
63 AC_HELP_STRING([--enable-swig-python],
64 [build SWIG interfaces for Python]),
65 enable_pyswig="$enableval")
66 if test "x${enable_pyswig}" = xyes; then
67 if test ${do_swigify} = no; then
68- AC_PROG_SWIG(1.3.28)
69+ AC_PROG_SWIG(2.0.0)
70 fi
71- AM_PATH_PYTHON(2.3)
72 SWIG_PYTHON
73 do_swigify_python=yes
74 do_swigify=yes
75 fi
76 if test ${do_swigify} = "yes"; then
77- AC_PROG_SWIG(1.3.28)
78+ AC_PROG_SWIG(2.0.0)
79 fi
80 build_apol=yes
81 AC_ARG_ENABLE(swig-tcl,
82@@ -239,7 +241,7 @@ AC_ARG_ENABLE(swig-tcl,
83 enable_tclswig="$enableval", enable_tclswig="yes")
84 if test "x${enable_tclswig}" = xyes; then
85 if test ${do_swigify} = no; then
86- AC_PROG_SWIG(1.3.28)
87+ AC_PROG_SWIG(2.0.0)
88 fi
89 TEA_INIT(3.5)
90 TEA_PATH_TCLCONFIG
91@@ -888,6 +890,8 @@ AC_CONFIG_FILES([Makefile VERSION \
92 sediff/Makefile \
93 man/Makefile \
94 debian/Makefile \
95+ python/Makefile \
96+ python/setools/Makefile \
97 packages/Makefile packages/rpm/Makefile \
98 packages/libqpol.pc packages/libapol.pc packages/libpoldiff.pc packages/libseaudit.pc packages/libsefs.pc])
99
100diff --git a/python/Makefile.am b/python/Makefile.am
101new file mode 100644
102index 0000000..a1510c8
103--- /dev/null
104+++ b/python/Makefile.am
105@@ -0,0 +1 @@
106+SUBDIRS = setools
107diff --git a/python/Makefile.in b/python/Makefile.in
108new file mode 100644
109index 0000000..48c87ab
110--- /dev/null
111+++ b/python/Makefile.in
112@@ -0,0 +1,716 @@
113+# Makefile.in generated by automake 1.11.1 from Makefile.am.
114+# @configure_input@
115+
116+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
117+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
118+# Inc.
119+# This Makefile.in is free software; the Free Software Foundation
120+# gives unlimited permission to copy and/or distribute it,
121+# with or without modifications, as long as this notice is preserved.
122+
123+# This program is distributed in the hope that it will be useful,
124+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
125+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
126+# PARTICULAR PURPOSE.
127+
128+@SET_MAKE@
129+VPATH = @srcdir@
130+pkgdatadir = $(datadir)/@PACKAGE@
131+pkgincludedir = $(includedir)/@PACKAGE@
132+pkglibdir = $(libdir)/@PACKAGE@
133+pkglibexecdir = $(libexecdir)/@PACKAGE@
134+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
135+install_sh_DATA = $(install_sh) -c -m 644
136+install_sh_PROGRAM = $(install_sh) -c
137+install_sh_SCRIPT = $(install_sh) -c
138+INSTALL_HEADER = $(INSTALL_DATA)
139+transform = $(program_transform_name)
140+NORMAL_INSTALL = :
141+PRE_INSTALL = :
142+POST_INSTALL = :
143+NORMAL_UNINSTALL = :
144+PRE_UNINSTALL = :
145+POST_UNINSTALL = :
146+build_triplet = @build@
147+host_triplet = @host@
148+subdir = python
149+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
150+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
151+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
152+ $(top_srcdir)/m4/ac_java_options.m4 \
153+ $(top_srcdir)/m4/ac_pkg_swig.m4 \
154+ $(top_srcdir)/m4/ac_prog_jar.m4 \
155+ $(top_srcdir)/m4/ac_prog_java.m4 \
156+ $(top_srcdir)/m4/ac_prog_java_works.m4 \
157+ $(top_srcdir)/m4/ac_prog_javac.m4 \
158+ $(top_srcdir)/m4/ac_prog_javac_works.m4 \
159+ $(top_srcdir)/m4/ac_python_devel.m4 $(top_srcdir)/m4/c.m4 \
160+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
161+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
162+ $(top_srcdir)/m4/lt~obsolete.m4 \
163+ $(top_srcdir)/m4/swig_python.m4 $(top_srcdir)/m4/tcl.m4 \
164+ $(top_srcdir)/configure.ac
165+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
166+ $(ACLOCAL_M4)
167+mkinstalldirs = $(install_sh) -d
168+CONFIG_HEADER = $(top_builddir)/config.h
169+CONFIG_CLEAN_FILES =
170+CONFIG_CLEAN_VPATH_FILES =
171+SOURCES =
172+DIST_SOURCES =
173+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
174+ html-recursive info-recursive install-data-recursive \
175+ install-dvi-recursive install-exec-recursive \
176+ install-html-recursive install-info-recursive \
177+ install-pdf-recursive install-ps-recursive install-recursive \
178+ installcheck-recursive installdirs-recursive pdf-recursive \
179+ ps-recursive uninstall-recursive
180+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
181+ distclean-recursive maintainer-clean-recursive
182+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
183+ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
184+ distdir
185+ETAGS = etags
186+CTAGS = ctags
187+DIST_SUBDIRS = $(SUBDIRS)
188+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
189+am__relativize = \
190+ dir0=`pwd`; \
191+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
192+ sed_rest='s,^[^/]*/*,,'; \
193+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
194+ sed_butlast='s,/*[^/]*$$,,'; \
195+ while test -n "$$dir1"; do \
196+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
197+ if test "$$first" != "."; then \
198+ if test "$$first" = ".."; then \
199+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
200+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
201+ else \
202+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
203+ if test "$$first2" = "$$first"; then \
204+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
205+ else \
206+ dir2="../$$dir2"; \
207+ fi; \
208+ dir0="$$dir0"/"$$first"; \
209+ fi; \
210+ fi; \
211+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
212+ done; \
213+ reldir="$$dir2"
214+ACLOCAL = @ACLOCAL@
215+AMTAR = @AMTAR@
216+APOL_CFLAGS = @APOL_CFLAGS@
217+APOL_LIB_FLAG = @APOL_LIB_FLAG@
218+AR = @AR@
219+AUTOCONF = @AUTOCONF@
220+AUTOHEADER = @AUTOHEADER@
221+AUTOMAKE = @AUTOMAKE@
222+AWK = @AWK@
223+BWIDGET_DESTDIR = @BWIDGET_DESTDIR@
224+CC = @CC@
225+CCDEPMODE = @CCDEPMODE@
226+CFLAGS = @CFLAGS@
227+CPP = @CPP@
228+CPPFLAGS = @CPPFLAGS@
229+CUNIT_LIB_FLAG = @CUNIT_LIB_FLAG@
230+CXX = @CXX@
231+CXXCPP = @CXXCPP@
232+CXXDEPMODE = @CXXDEPMODE@
233+CXXFLAGS = @CXXFLAGS@
234+CYGPATH = @CYGPATH@
235+CYGPATH_W = @CYGPATH_W@
236+DEBUGCFLAGS = @DEBUGCFLAGS@
237+DEBUGCXXFLAGS = @DEBUGCXXFLAGS@
238+DEBUGJFLAGS = @DEBUGJFLAGS@
239+DEBUGLDFLAGS = @DEBUGLDFLAGS@
240+DEFS = @DEFS@
241+DEPDIR = @DEPDIR@
242+DSYMUTIL = @DSYMUTIL@
243+DUMPBIN = @DUMPBIN@
244+ECHO_C = @ECHO_C@
245+ECHO_N = @ECHO_N@
246+ECHO_T = @ECHO_T@
247+EGREP = @EGREP@
248+EXEEXT = @EXEEXT@
249+FGREP = @FGREP@
250+GLADE_CFLAGS = @GLADE_CFLAGS@
251+GLADE_LIBS = @GLADE_LIBS@
252+GREP = @GREP@
253+GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
254+GTHREAD_LIBS = @GTHREAD_LIBS@
255+GTK_CFLAGS = @GTK_CFLAGS@
256+GTK_LIBS = @GTK_LIBS@
257+INSTALL = @INSTALL@
258+INSTALL_DATA = @INSTALL_DATA@
259+INSTALL_PROGRAM = @INSTALL_PROGRAM@
260+INSTALL_SCRIPT = @INSTALL_SCRIPT@
261+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
262+JAR = @JAR@
263+JAVA = @JAVA@
264+JAVAC = @JAVAC@
265+JAVACFLAGS = @JAVACFLAGS@
266+JAVAFLAGS = @JAVAFLAGS@
267+JAVAPREFIX = @JAVAPREFIX@
268+LD = @LD@
269+LDFLAGS = @LDFLAGS@
270+LEX = @LEX@
271+LEXLIB = @LEXLIB@
272+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
273+LIBOBJS = @LIBOBJS@
274+LIBS = @LIBS@
275+LIBTOOL = @LIBTOOL@
276+LIPO = @LIPO@
277+LN_S = @LN_S@
278+LTLIBOBJS = @LTLIBOBJS@
279+MAKEINFO = @MAKEINFO@
280+MKDIR_P = @MKDIR_P@
281+NM = @NM@
282+NMEDIT = @NMEDIT@
283+OBJDUMP = @OBJDUMP@
284+OBJEXT = @OBJEXT@
285+OTOOL = @OTOOL@
286+OTOOL64 = @OTOOL64@
287+PACKAGE = @PACKAGE@
288+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
289+PACKAGE_NAME = @PACKAGE_NAME@
290+PACKAGE_STRING = @PACKAGE_STRING@
291+PACKAGE_TARNAME = @PACKAGE_TARNAME@
292+PACKAGE_URL = @PACKAGE_URL@
293+PACKAGE_VERSION = @PACKAGE_VERSION@
294+PATH_SEPARATOR = @PATH_SEPARATOR@
295+PIXBUF_CFLAGS = @PIXBUF_CFLAGS@
296+PIXBUF_LIBS = @PIXBUF_LIBS@
297+PKG_CFLAGS = @PKG_CFLAGS@
298+PKG_HEADERS = @PKG_HEADERS@
299+PKG_INCLUDES = @PKG_INCLUDES@
300+PKG_LIBS = @PKG_LIBS@
301+PKG_LIB_FILE = @PKG_LIB_FILE@
302+PKG_STUB_LIB_FILE = @PKG_STUB_LIB_FILE@
303+PKG_STUB_OBJECTS = @PKG_STUB_OBJECTS@
304+PKG_STUB_SOURCES = @PKG_STUB_SOURCES@
305+PKG_TCL_SOURCES = @PKG_TCL_SOURCES@
306+POLDIFF_CFLAGS = @POLDIFF_CFLAGS@
307+POLDIFF_LIB_FLAG = @POLDIFF_LIB_FLAG@
308+PROFILECFLAGS = @PROFILECFLAGS@
309+PROFILELDFLAGS = @PROFILELDFLAGS@
310+PYTHON = @PYTHON@
311+PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
312+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
313+PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@
314+PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@
315+PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
316+PYTHON_PLATFORM = @PYTHON_PLATFORM@
317+PYTHON_PREFIX = @PYTHON_PREFIX@
318+PYTHON_SITE_PKG = @PYTHON_SITE_PKG@
319+PYTHON_VERSION = @PYTHON_VERSION@
320+QPOL_CFLAGS = @QPOL_CFLAGS@
321+QPOL_LIB_FLAG = @QPOL_LIB_FLAG@
322+RANLIB = @RANLIB@
323+SEAUDIT_CFLAGS = @SEAUDIT_CFLAGS@
324+SEAUDIT_LIB_FLAG = @SEAUDIT_LIB_FLAG@
325+SED = @SED@
326+SEFS_CFLAGS = @SEFS_CFLAGS@
327+SEFS_LIB_FLAG = @SEFS_LIB_FLAG@
328+SELINUX_CFLAGS = @SELINUX_CFLAGS@
329+SELINUX_LIB_FLAG = @SELINUX_LIB_FLAG@
330+SET_MAKE = @SET_MAKE@
331+SHELL = @SHELL@
332+SQLITE3_CFLAGS = @SQLITE3_CFLAGS@
333+SQLITE3_LIBS = @SQLITE3_LIBS@
334+STRIP = @STRIP@
335+SWIG = @SWIG@
336+SWIG_JAVA_CFLAGS = @SWIG_JAVA_CFLAGS@
337+SWIG_JAVA_OPT = @SWIG_JAVA_OPT@
338+SWIG_LIB = @SWIG_LIB@
339+SWIG_PYTHON_CPPFLAGS = @SWIG_PYTHON_CPPFLAGS@
340+SWIG_PYTHON_OPT = @SWIG_PYTHON_OPT@
341+SWIG_TCL_CFLAGS = @SWIG_TCL_CFLAGS@
342+SWIG_TCL_OPT = @SWIG_TCL_OPT@
343+TCLSH_PROG = @TCLSH_PROG@
344+TCL_AUTOPATH = @TCL_AUTOPATH@
345+TCL_BIN_DIR = @TCL_BIN_DIR@
346+TCL_DEFS = @TCL_DEFS@
347+TCL_EXTRA_CFLAGS = @TCL_EXTRA_CFLAGS@
348+TCL_INCLUDES = @TCL_INCLUDES@
349+TCL_LD_FLAGS = @TCL_LD_FLAGS@
350+TCL_LIBS = @TCL_LIBS@
351+TCL_LIB_FILE = @TCL_LIB_FILE@
352+TCL_LIB_FLAG = @TCL_LIB_FLAG@
353+TCL_LIB_SPEC = @TCL_LIB_SPEC@
354+TCL_SHLIB_LD_LIBS = @TCL_SHLIB_LD_LIBS@
355+TCL_SRC_DIR = @TCL_SRC_DIR@
356+TCL_STUB_LIB_FILE = @TCL_STUB_LIB_FILE@
357+TCL_STUB_LIB_FLAG = @TCL_STUB_LIB_FLAG@
358+TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@
359+TCL_VERSION = @TCL_VERSION@
360+TK_BIN_DIR = @TK_BIN_DIR@
361+TK_INCLUDES = @TK_INCLUDES@
362+TK_LIBS = @TK_LIBS@
363+TK_LIB_FILE = @TK_LIB_FILE@
364+TK_LIB_FLAG = @TK_LIB_FLAG@
365+TK_LIB_SPEC = @TK_LIB_SPEC@
366+TK_SRC_DIR = @TK_SRC_DIR@
367+TK_STUB_LIB_FILE = @TK_STUB_LIB_FILE@
368+TK_STUB_LIB_FLAG = @TK_STUB_LIB_FLAG@
369+TK_STUB_LIB_SPEC = @TK_STUB_LIB_SPEC@
370+TK_VERSION = @TK_VERSION@
371+TK_XINCLUDES = @TK_XINCLUDES@
372+VERSION = @VERSION@
373+WARNCFLAGS = @WARNCFLAGS@
374+WARNCXXFLAGS = @WARNCXXFLAGS@
375+WARNJFLAGS = @WARNJFLAGS@
376+WARNLDFLAGS = @WARNLDFLAGS@
377+WISH_PROG = @WISH_PROG@
378+XMKMF = @XMKMF@
379+XML_CFLAGS = @XML_CFLAGS@
380+XML_LIBS = @XML_LIBS@
381+YACC = @YACC@
382+YFLAGS = @YFLAGS@
383+abs_builddir = @abs_builddir@
384+abs_srcdir = @abs_srcdir@
385+abs_top_builddir = @abs_top_builddir@
386+abs_top_srcdir = @abs_top_srcdir@
387+ac_ct_CC = @ac_ct_CC@
388+ac_ct_CXX = @ac_ct_CXX@
389+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
390+am__include = @am__include@
391+am__leading_dot = @am__leading_dot@
392+am__quote = @am__quote@
393+am__tar = @am__tar@
394+am__untar = @am__untar@
395+bindir = @bindir@
396+build = @build@
397+build_alias = @build_alias@
398+build_cpu = @build_cpu@
399+build_os = @build_os@
400+build_vendor = @build_vendor@
401+builddir = @builddir@
402+datadir = @datadir@
403+datarootdir = @datarootdir@
404+docdir = @docdir@
405+dvidir = @dvidir@
406+exec_prefix = @exec_prefix@
407+has_pkg_config = @has_pkg_config@
408+host = @host@
409+host_alias = @host_alias@
410+host_cpu = @host_cpu@
411+host_os = @host_os@
412+host_vendor = @host_vendor@
413+htmldir = @htmldir@
414+includedir = @includedir@
415+infodir = @infodir@
416+install_sh = @install_sh@
417+javadir = @javadir@
418+libapol_jswig_soname = @libapol_jswig_soname@
419+libapol_pyswig_soname = @libapol_pyswig_soname@
420+libapol_soname = @libapol_soname@
421+libapol_soversion = @libapol_soversion@
422+libapol_tswig_soname = @libapol_tswig_soname@
423+libapol_version = @libapol_version@
424+libdir = @libdir@
425+libexecdir = @libexecdir@
426+libpoldiff_jswig_soname = @libpoldiff_jswig_soname@
427+libpoldiff_pyswig_soname = @libpoldiff_pyswig_soname@
428+libpoldiff_soname = @libpoldiff_soname@
429+libpoldiff_soversion = @libpoldiff_soversion@
430+libpoldiff_tswig_soname = @libpoldiff_tswig_soname@
431+libpoldiff_version = @libpoldiff_version@
432+libqpol_jswig_soname = @libqpol_jswig_soname@
433+libqpol_pyswig_soname = @libqpol_pyswig_soname@
434+libqpol_soname = @libqpol_soname@
435+libqpol_soversion = @libqpol_soversion@
436+libqpol_tswig_soname = @libqpol_tswig_soname@
437+libqpol_version = @libqpol_version@
438+libseaudit_jswig_soname = @libseaudit_jswig_soname@
439+libseaudit_pyswig_soname = @libseaudit_pyswig_soname@
440+libseaudit_soname = @libseaudit_soname@
441+libseaudit_soversion = @libseaudit_soversion@
442+libseaudit_tswig_soname = @libseaudit_tswig_soname@
443+libseaudit_version = @libseaudit_version@
444+libsefs_jswig_soname = @libsefs_jswig_soname@
445+libsefs_pyswig_soname = @libsefs_pyswig_soname@
446+libsefs_soname = @libsefs_soname@
447+libsefs_soversion = @libsefs_soversion@
448+libsefs_tswig_soname = @libsefs_tswig_soname@
449+libsefs_version = @libsefs_version@
450+localedir = @localedir@
451+localstatedir = @localstatedir@
452+lt_ECHO = @lt_ECHO@
453+mandir = @mandir@
454+mkdir_p = @mkdir_p@
455+oldincludedir = @oldincludedir@
456+pdfdir = @pdfdir@
457+pkgpyexecdir = @pkgpyexecdir@
458+pkgpythondir = @pkgpythondir@
459+prefix = @prefix@
460+profile_install_dir = @profile_install_dir@
461+program_transform_name = @program_transform_name@
462+psdir = @psdir@
463+pyexecdir = @pyexecdir@
464+pythondir = @pythondir@
465+sbindir = @sbindir@
466+selinux_default_policy = @selinux_default_policy@
467+selinux_policy_dir = @selinux_policy_dir@
468+sepol_srcdir = @sepol_srcdir@
469+setoolsdir = @setoolsdir@
470+sharedstatedir = @sharedstatedir@
471+srcdir = @srcdir@
472+sysconfdir = @sysconfdir@
473+target_alias = @target_alias@
474+top_build_prefix = @top_build_prefix@
475+top_builddir = @top_builddir@
476+top_srcdir = @top_srcdir@
477+uudecode = @uudecode@
478+SUBDIRS = setools
479+all: all-recursive
480+
481+.SUFFIXES:
482+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
483+ @for dep in $?; do \
484+ case '$(am__configure_deps)' in \
485+ *$$dep*) \
486+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
487+ && { if test -f $@; then exit 0; else break; fi; }; \
488+ exit 1;; \
489+ esac; \
490+ done; \
491+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu python/Makefile'; \
492+ $(am__cd) $(top_srcdir) && \
493+ $(AUTOMAKE) --gnu python/Makefile
494+.PRECIOUS: Makefile
495+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
496+ @case '$?' in \
497+ *config.status*) \
498+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
499+ *) \
500+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
501+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
502+ esac;
503+
504+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
505+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
506+
507+$(top_srcdir)/configure: $(am__configure_deps)
508+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
509+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
510+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
511+$(am__aclocal_m4_deps):
512+
513+mostlyclean-libtool:
514+ -rm -f *.lo
515+
516+clean-libtool:
517+ -rm -rf .libs _libs
518+
519+# This directory's subdirectories are mostly independent; you can cd
520+# into them and run `make' without going through this Makefile.
521+# To change the values of `make' variables: instead of editing Makefiles,
522+# (1) if the variable is set in `config.status', edit `config.status'
523+# (which will cause the Makefiles to be regenerated when you run `make');
524+# (2) otherwise, pass the desired values on the `make' command line.
525+$(RECURSIVE_TARGETS):
526+ @fail= failcom='exit 1'; \
527+ for f in x $$MAKEFLAGS; do \
528+ case $$f in \
529+ *=* | --[!k]*);; \
530+ *k*) failcom='fail=yes';; \
531+ esac; \
532+ done; \
533+ dot_seen=no; \
534+ target=`echo $@ | sed s/-recursive//`; \
535+ list='$(SUBDIRS)'; for subdir in $$list; do \
536+ echo "Making $$target in $$subdir"; \
537+ if test "$$subdir" = "."; then \
538+ dot_seen=yes; \
539+ local_target="$$target-am"; \
540+ else \
541+ local_target="$$target"; \
542+ fi; \
543+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
544+ || eval $$failcom; \
545+ done; \
546+ if test "$$dot_seen" = "no"; then \
547+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
548+ fi; test -z "$$fail"
549+
550+$(RECURSIVE_CLEAN_TARGETS):
551+ @fail= failcom='exit 1'; \
552+ for f in x $$MAKEFLAGS; do \
553+ case $$f in \
554+ *=* | --[!k]*);; \
555+ *k*) failcom='fail=yes';; \
556+ esac; \
557+ done; \
558+ dot_seen=no; \
559+ case "$@" in \
560+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
561+ *) list='$(SUBDIRS)' ;; \
562+ esac; \
563+ rev=''; for subdir in $$list; do \
564+ if test "$$subdir" = "."; then :; else \
565+ rev="$$subdir $$rev"; \
566+ fi; \
567+ done; \
568+ rev="$$rev ."; \
569+ target=`echo $@ | sed s/-recursive//`; \
570+ for subdir in $$rev; do \
571+ echo "Making $$target in $$subdir"; \
572+ if test "$$subdir" = "."; then \
573+ local_target="$$target-am"; \
574+ else \
575+ local_target="$$target"; \
576+ fi; \
577+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
578+ || eval $$failcom; \
579+ done && test -z "$$fail"
580+tags-recursive:
581+ list='$(SUBDIRS)'; for subdir in $$list; do \
582+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
583+ done
584+ctags-recursive:
585+ list='$(SUBDIRS)'; for subdir in $$list; do \
586+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
587+ done
588+
589+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
590+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
591+ unique=`for i in $$list; do \
592+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
593+ done | \
594+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
595+ END { if (nonempty) { for (i in files) print i; }; }'`; \
596+ mkid -fID $$unique
597+tags: TAGS
598+
599+TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
600+ $(TAGS_FILES) $(LISP)
601+ set x; \
602+ here=`pwd`; \
603+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
604+ include_option=--etags-include; \
605+ empty_fix=.; \
606+ else \
607+ include_option=--include; \
608+ empty_fix=; \
609+ fi; \
610+ list='$(SUBDIRS)'; for subdir in $$list; do \
611+ if test "$$subdir" = .; then :; else \
612+ test ! -f $$subdir/TAGS || \
613+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
614+ fi; \
615+ done; \
616+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
617+ unique=`for i in $$list; do \
618+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
619+ done | \
620+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
621+ END { if (nonempty) { for (i in files) print i; }; }'`; \
622+ shift; \
623+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
624+ test -n "$$unique" || unique=$$empty_fix; \
625+ if test $$# -gt 0; then \
626+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
627+ "$$@" $$unique; \
628+ else \
629+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
630+ $$unique; \
631+ fi; \
632+ fi
633+ctags: CTAGS
634+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
635+ $(TAGS_FILES) $(LISP)
636+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
637+ unique=`for i in $$list; do \
638+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
639+ done | \
640+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
641+ END { if (nonempty) { for (i in files) print i; }; }'`; \
642+ test -z "$(CTAGS_ARGS)$$unique" \
643+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
644+ $$unique
645+
646+GTAGS:
647+ here=`$(am__cd) $(top_builddir) && pwd` \
648+ && $(am__cd) $(top_srcdir) \
649+ && gtags -i $(GTAGS_ARGS) "$$here"
650+
651+distclean-tags:
652+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
653+
654+distdir: $(DISTFILES)
655+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
656+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
657+ list='$(DISTFILES)'; \
658+ dist_files=`for file in $$list; do echo $$file; done | \
659+ sed -e "s|^$$srcdirstrip/||;t" \
660+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
661+ case $$dist_files in \
662+ */*) $(MKDIR_P) `echo "$$dist_files" | \
663+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
664+ sort -u` ;; \
665+ esac; \
666+ for file in $$dist_files; do \
667+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
668+ if test -d $$d/$$file; then \
669+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
670+ if test -d "$(distdir)/$$file"; then \
671+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
672+ fi; \
673+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
674+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
675+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
676+ fi; \
677+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
678+ else \
679+ test -f "$(distdir)/$$file" \
680+ || cp -p $$d/$$file "$(distdir)/$$file" \
681+ || exit 1; \
682+ fi; \
683+ done
684+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
685+ if test "$$subdir" = .; then :; else \
686+ test -d "$(distdir)/$$subdir" \
687+ || $(MKDIR_P) "$(distdir)/$$subdir" \
688+ || exit 1; \
689+ fi; \
690+ done
691+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
692+ if test "$$subdir" = .; then :; else \
693+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
694+ $(am__relativize); \
695+ new_distdir=$$reldir; \
696+ dir1=$$subdir; dir2="$(top_distdir)"; \
697+ $(am__relativize); \
698+ new_top_distdir=$$reldir; \
699+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
700+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
701+ ($(am__cd) $$subdir && \
702+ $(MAKE) $(AM_MAKEFLAGS) \
703+ top_distdir="$$new_top_distdir" \
704+ distdir="$$new_distdir" \
705+ am__remove_distdir=: \
706+ am__skip_length_check=: \
707+ am__skip_mode_fix=: \
708+ distdir) \
709+ || exit 1; \
710+ fi; \
711+ done
712+check-am: all-am
713+check: check-recursive
714+all-am: Makefile
715+installdirs: installdirs-recursive
716+installdirs-am:
717+install: install-recursive
718+install-exec: install-exec-recursive
719+install-data: install-data-recursive
720+uninstall: uninstall-recursive
721+
722+install-am: all-am
723+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
724+
725+installcheck: installcheck-recursive
726+install-strip:
727+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
728+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
729+ `test -z '$(STRIP)' || \
730+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
731+mostlyclean-generic:
732+
733+clean-generic:
734+
735+distclean-generic:
736+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
737+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
738+
739+maintainer-clean-generic:
740+ @echo "This command is intended for maintainers to use"
741+ @echo "it deletes files that may require special tools to rebuild."
742+clean: clean-recursive
743+
744+clean-am: clean-generic clean-libtool mostlyclean-am
745+
746+distclean: distclean-recursive
747+ -rm -f Makefile
748+distclean-am: clean-am distclean-generic distclean-tags
749+
750+dvi: dvi-recursive
751+
752+dvi-am:
753+
754+html: html-recursive
755+
756+html-am:
757+
758+info: info-recursive
759+
760+info-am:
761+
762+install-data-am:
763+
764+install-dvi: install-dvi-recursive
765+
766+install-dvi-am:
767+
768+install-exec-am:
769+
770+install-html: install-html-recursive
771+
772+install-html-am:
773+
774+install-info: install-info-recursive
775+
776+install-info-am:
777+
778+install-man:
779+
780+install-pdf: install-pdf-recursive
781+
782+install-pdf-am:
783+
784+install-ps: install-ps-recursive
785+
786+install-ps-am:
787+
788+installcheck-am:
789+
790+maintainer-clean: maintainer-clean-recursive
791+ -rm -f Makefile
792+maintainer-clean-am: distclean-am maintainer-clean-generic
793+
794+mostlyclean: mostlyclean-recursive
795+
796+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
797+
798+pdf: pdf-recursive
799+
800+pdf-am:
801+
802+ps: ps-recursive
803+
804+ps-am:
805+
806+uninstall-am:
807+
808+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
809+ install-am install-strip tags-recursive
810+
811+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
812+ all all-am check check-am clean clean-generic clean-libtool \
813+ ctags ctags-recursive distclean distclean-generic \
814+ distclean-libtool distclean-tags distdir dvi dvi-am html \
815+ html-am info info-am install install-am install-data \
816+ install-data-am install-dvi install-dvi-am install-exec \
817+ install-exec-am install-html install-html-am install-info \
818+ install-info-am install-man install-pdf install-pdf-am \
819+ install-ps install-ps-am install-strip installcheck \
820+ installcheck-am installdirs installdirs-am maintainer-clean \
821+ maintainer-clean-generic mostlyclean mostlyclean-generic \
822+ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
823+ uninstall uninstall-am
824+
825+
826+# Tell versions [3.59,3.63) of GNU make to not export all variables.
827+# Otherwise a system limit (for SysV at least) may be exceeded.
828+.NOEXPORT:
829diff --git a/python/setools/Makefile.am b/python/setools/Makefile.am
830new file mode 100644
831index 0000000..c4635fb
832--- /dev/null
833+++ b/python/setools/Makefile.am
834@@ -0,0 +1,36 @@
835+EXTRA_DIST = \
836+ sesearch.c \
837+ seinfo.c \
838+ __init__.py \
839+ setup.py \
840+ $(NULL)
841+
842+AM_CFLAGS = @DEBUGCFLAGS@ @WARNCFLAGS@ @PROFILECFLAGS@ @SELINUX_CFLAGS@ \
843+ @QPOL_CFLAGS@ @APOL_CFLAGS@
844+AM_CXXFLAGS = @DEBUGCXXFLAGS@ @WARNCXXFLAGS@ @PROFILECFLAGS@ @SELINUX_CFLAGS@ \
845+ @QPOL_CFLAGS@ @APOL_CFLAGS@ @SEFS_CFLAGS@
846+AM_LDFLAGS = @DEBUGLDFLAGS@ @WARNLDFLAGS@ @PROFILELDFLAGS@
847+
848+LDADD = @SELINUX_LIB_FLAG@ @APOL_LIB_FLAG@ @QPOL_LIB_FLAG@
849+DEPENDENCIES = $(top_builddir)/libapol/src/libapol.so $(top_builddir)/libqpol/src/libqpol.so
850+all-am: python-build
851+
852+seinfo_SOURCES = seinfo.c
853+
854+sesearch_SOURCES = sesearch.c
855+
856+python-build: sesearch.c seinfo.c
857+ @mkdir -p setools
858+ @cp __init__.py setools
859+ LIBS="$(QPOL_LIB_FLAG) $(APOL_LIB_FLAG)" INCLUDES="$(QPOL_CFLAGS) $(APOL_CFLAGS)" $(PYTHON) setup.py build
860+
861+install-exec-hook:
862+ $(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
863+
864+uninstall-hook:
865+ $(PYTHON) setup.py uninstall `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
866+
867+clean-local:
868+ $(PYTHON) setup.py clean -a
869+ rm -f *~
870+
871diff --git a/python/setools/Makefile.in b/python/setools/Makefile.in
872new file mode 100644
873index 0000000..704ffc7
874--- /dev/null
875+++ b/python/setools/Makefile.in
876@@ -0,0 +1,550 @@
877+# Makefile.in generated by automake 1.11.1 from Makefile.am.
878+# @configure_input@
879+
880+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
881+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
882+# Inc.
883+# This Makefile.in is free software; the Free Software Foundation
884+# gives unlimited permission to copy and/or distribute it,
885+# with or without modifications, as long as this notice is preserved.
886+
887+# This program is distributed in the hope that it will be useful,
888+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
889+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
890+# PARTICULAR PURPOSE.
891+
892+@SET_MAKE@
893+VPATH = @srcdir@
894+pkgdatadir = $(datadir)/@PACKAGE@
895+pkgincludedir = $(includedir)/@PACKAGE@
896+pkglibdir = $(libdir)/@PACKAGE@
897+pkglibexecdir = $(libexecdir)/@PACKAGE@
898+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
899+install_sh_DATA = $(install_sh) -c -m 644
900+install_sh_PROGRAM = $(install_sh) -c
901+install_sh_SCRIPT = $(install_sh) -c
902+INSTALL_HEADER = $(INSTALL_DATA)
903+transform = $(program_transform_name)
904+NORMAL_INSTALL = :
905+PRE_INSTALL = :
906+POST_INSTALL = :
907+NORMAL_UNINSTALL = :
908+PRE_UNINSTALL = :
909+POST_UNINSTALL = :
910+build_triplet = @build@
911+host_triplet = @host@
912+subdir = python/setools
913+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
914+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
915+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
916+ $(top_srcdir)/m4/ac_java_options.m4 \
917+ $(top_srcdir)/m4/ac_pkg_swig.m4 \
918+ $(top_srcdir)/m4/ac_prog_jar.m4 \
919+ $(top_srcdir)/m4/ac_prog_java.m4 \
920+ $(top_srcdir)/m4/ac_prog_java_works.m4 \
921+ $(top_srcdir)/m4/ac_prog_javac.m4 \
922+ $(top_srcdir)/m4/ac_prog_javac_works.m4 \
923+ $(top_srcdir)/m4/ac_python_devel.m4 $(top_srcdir)/m4/c.m4 \
924+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
925+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
926+ $(top_srcdir)/m4/lt~obsolete.m4 \
927+ $(top_srcdir)/m4/swig_python.m4 $(top_srcdir)/m4/tcl.m4 \
928+ $(top_srcdir)/configure.ac
929+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
930+ $(ACLOCAL_M4)
931+mkinstalldirs = $(install_sh) -d
932+CONFIG_HEADER = $(top_builddir)/config.h
933+CONFIG_CLEAN_FILES =
934+CONFIG_CLEAN_VPATH_FILES =
935+SOURCES =
936+DIST_SOURCES =
937+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
938+ACLOCAL = @ACLOCAL@
939+AMTAR = @AMTAR@
940+APOL_CFLAGS = @APOL_CFLAGS@
941+APOL_LIB_FLAG = @APOL_LIB_FLAG@
942+AR = @AR@
943+AUTOCONF = @AUTOCONF@
944+AUTOHEADER = @AUTOHEADER@
945+AUTOMAKE = @AUTOMAKE@
946+AWK = @AWK@
947+BWIDGET_DESTDIR = @BWIDGET_DESTDIR@
948+CC = @CC@
949+CCDEPMODE = @CCDEPMODE@
950+CFLAGS = @CFLAGS@
951+CPP = @CPP@
952+CPPFLAGS = @CPPFLAGS@
953+CUNIT_LIB_FLAG = @CUNIT_LIB_FLAG@
954+CXX = @CXX@
955+CXXCPP = @CXXCPP@
956+CXXDEPMODE = @CXXDEPMODE@
957+CXXFLAGS = @CXXFLAGS@
958+CYGPATH = @CYGPATH@
959+CYGPATH_W = @CYGPATH_W@
960+DEBUGCFLAGS = @DEBUGCFLAGS@
961+DEBUGCXXFLAGS = @DEBUGCXXFLAGS@
962+DEBUGJFLAGS = @DEBUGJFLAGS@
963+DEBUGLDFLAGS = @DEBUGLDFLAGS@
964+DEFS = @DEFS@
965+DEPDIR = @DEPDIR@
966+DSYMUTIL = @DSYMUTIL@
967+DUMPBIN = @DUMPBIN@
968+ECHO_C = @ECHO_C@
969+ECHO_N = @ECHO_N@
970+ECHO_T = @ECHO_T@
971+EGREP = @EGREP@
972+EXEEXT = @EXEEXT@
973+FGREP = @FGREP@
974+GLADE_CFLAGS = @GLADE_CFLAGS@
975+GLADE_LIBS = @GLADE_LIBS@
976+GREP = @GREP@
977+GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
978+GTHREAD_LIBS = @GTHREAD_LIBS@
979+GTK_CFLAGS = @GTK_CFLAGS@
980+GTK_LIBS = @GTK_LIBS@
981+INSTALL = @INSTALL@
982+INSTALL_DATA = @INSTALL_DATA@
983+INSTALL_PROGRAM = @INSTALL_PROGRAM@
984+INSTALL_SCRIPT = @INSTALL_SCRIPT@
985+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
986+JAR = @JAR@
987+JAVA = @JAVA@
988+JAVAC = @JAVAC@
989+JAVACFLAGS = @JAVACFLAGS@
990+JAVAFLAGS = @JAVAFLAGS@
991+JAVAPREFIX = @JAVAPREFIX@
992+LD = @LD@
993+LDFLAGS = @LDFLAGS@
994+LEX = @LEX@
995+LEXLIB = @LEXLIB@
996+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
997+LIBOBJS = @LIBOBJS@
998+LIBS = @LIBS@
999+LIBTOOL = @LIBTOOL@
1000+LIPO = @LIPO@
1001+LN_S = @LN_S@
1002+LTLIBOBJS = @LTLIBOBJS@
1003+MAKEINFO = @MAKEINFO@
1004+MKDIR_P = @MKDIR_P@
1005+NM = @NM@
1006+NMEDIT = @NMEDIT@
1007+OBJDUMP = @OBJDUMP@
1008+OBJEXT = @OBJEXT@
1009+OTOOL = @OTOOL@
1010+OTOOL64 = @OTOOL64@
1011+PACKAGE = @PACKAGE@
1012+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
1013+PACKAGE_NAME = @PACKAGE_NAME@
1014+PACKAGE_STRING = @PACKAGE_STRING@
1015+PACKAGE_TARNAME = @PACKAGE_TARNAME@
1016+PACKAGE_URL = @PACKAGE_URL@
1017+PACKAGE_VERSION = @PACKAGE_VERSION@
1018+PATH_SEPARATOR = @PATH_SEPARATOR@
1019+PIXBUF_CFLAGS = @PIXBUF_CFLAGS@
1020+PIXBUF_LIBS = @PIXBUF_LIBS@
1021+PKG_CFLAGS = @PKG_CFLAGS@
1022+PKG_HEADERS = @PKG_HEADERS@
1023+PKG_INCLUDES = @PKG_INCLUDES@
1024+PKG_LIBS = @PKG_LIBS@
1025+PKG_LIB_FILE = @PKG_LIB_FILE@
1026+PKG_STUB_LIB_FILE = @PKG_STUB_LIB_FILE@
1027+PKG_STUB_OBJECTS = @PKG_STUB_OBJECTS@
1028+PKG_STUB_SOURCES = @PKG_STUB_SOURCES@
1029+PKG_TCL_SOURCES = @PKG_TCL_SOURCES@
1030+POLDIFF_CFLAGS = @POLDIFF_CFLAGS@
1031+POLDIFF_LIB_FLAG = @POLDIFF_LIB_FLAG@
1032+PROFILECFLAGS = @PROFILECFLAGS@
1033+PROFILELDFLAGS = @PROFILELDFLAGS@
1034+PYTHON = @PYTHON@
1035+PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
1036+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
1037+PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@
1038+PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@
1039+PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
1040+PYTHON_PLATFORM = @PYTHON_PLATFORM@
1041+PYTHON_PREFIX = @PYTHON_PREFIX@
1042+PYTHON_SITE_PKG = @PYTHON_SITE_PKG@
1043+PYTHON_VERSION = @PYTHON_VERSION@
1044+QPOL_CFLAGS = @QPOL_CFLAGS@
1045+QPOL_LIB_FLAG = @QPOL_LIB_FLAG@
1046+RANLIB = @RANLIB@
1047+SEAUDIT_CFLAGS = @SEAUDIT_CFLAGS@
1048+SEAUDIT_LIB_FLAG = @SEAUDIT_LIB_FLAG@
1049+SED = @SED@
1050+SEFS_CFLAGS = @SEFS_CFLAGS@
1051+SEFS_LIB_FLAG = @SEFS_LIB_FLAG@
1052+SELINUX_CFLAGS = @SELINUX_CFLAGS@
1053+SELINUX_LIB_FLAG = @SELINUX_LIB_FLAG@
1054+SET_MAKE = @SET_MAKE@
1055+SHELL = @SHELL@
1056+SQLITE3_CFLAGS = @SQLITE3_CFLAGS@
1057+SQLITE3_LIBS = @SQLITE3_LIBS@
1058+STRIP = @STRIP@
1059+SWIG = @SWIG@
1060+SWIG_JAVA_CFLAGS = @SWIG_JAVA_CFLAGS@
1061+SWIG_JAVA_OPT = @SWIG_JAVA_OPT@
1062+SWIG_LIB = @SWIG_LIB@
1063+SWIG_PYTHON_CPPFLAGS = @SWIG_PYTHON_CPPFLAGS@
1064+SWIG_PYTHON_OPT = @SWIG_PYTHON_OPT@
1065+SWIG_TCL_CFLAGS = @SWIG_TCL_CFLAGS@
1066+SWIG_TCL_OPT = @SWIG_TCL_OPT@
1067+TCLSH_PROG = @TCLSH_PROG@
1068+TCL_AUTOPATH = @TCL_AUTOPATH@
1069+TCL_BIN_DIR = @TCL_BIN_DIR@
1070+TCL_DEFS = @TCL_DEFS@
1071+TCL_EXTRA_CFLAGS = @TCL_EXTRA_CFLAGS@
1072+TCL_INCLUDES = @TCL_INCLUDES@
1073+TCL_LD_FLAGS = @TCL_LD_FLAGS@
1074+TCL_LIBS = @TCL_LIBS@
1075+TCL_LIB_FILE = @TCL_LIB_FILE@
1076+TCL_LIB_FLAG = @TCL_LIB_FLAG@
1077+TCL_LIB_SPEC = @TCL_LIB_SPEC@
1078+TCL_SHLIB_LD_LIBS = @TCL_SHLIB_LD_LIBS@
1079+TCL_SRC_DIR = @TCL_SRC_DIR@
1080+TCL_STUB_LIB_FILE = @TCL_STUB_LIB_FILE@
1081+TCL_STUB_LIB_FLAG = @TCL_STUB_LIB_FLAG@
1082+TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@
1083+TCL_VERSION = @TCL_VERSION@
1084+TK_BIN_DIR = @TK_BIN_DIR@
1085+TK_INCLUDES = @TK_INCLUDES@
1086+TK_LIBS = @TK_LIBS@
1087+TK_LIB_FILE = @TK_LIB_FILE@
1088+TK_LIB_FLAG = @TK_LIB_FLAG@
1089+TK_LIB_SPEC = @TK_LIB_SPEC@
1090+TK_SRC_DIR = @TK_SRC_DIR@
1091+TK_STUB_LIB_FILE = @TK_STUB_LIB_FILE@
1092+TK_STUB_LIB_FLAG = @TK_STUB_LIB_FLAG@
1093+TK_STUB_LIB_SPEC = @TK_STUB_LIB_SPEC@
1094+TK_VERSION = @TK_VERSION@
1095+TK_XINCLUDES = @TK_XINCLUDES@
1096+VERSION = @VERSION@
1097+WARNCFLAGS = @WARNCFLAGS@
1098+WARNCXXFLAGS = @WARNCXXFLAGS@
1099+WARNJFLAGS = @WARNJFLAGS@
1100+WARNLDFLAGS = @WARNLDFLAGS@
1101+WISH_PROG = @WISH_PROG@
1102+XMKMF = @XMKMF@
1103+XML_CFLAGS = @XML_CFLAGS@
1104+XML_LIBS = @XML_LIBS@
1105+YACC = @YACC@
1106+YFLAGS = @YFLAGS@
1107+abs_builddir = @abs_builddir@
1108+abs_srcdir = @abs_srcdir@
1109+abs_top_builddir = @abs_top_builddir@
1110+abs_top_srcdir = @abs_top_srcdir@
1111+ac_ct_CC = @ac_ct_CC@
1112+ac_ct_CXX = @ac_ct_CXX@
1113+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
1114+am__include = @am__include@
1115+am__leading_dot = @am__leading_dot@
1116+am__quote = @am__quote@
1117+am__tar = @am__tar@
1118+am__untar = @am__untar@
1119+bindir = @bindir@
1120+build = @build@
1121+build_alias = @build_alias@
1122+build_cpu = @build_cpu@
1123+build_os = @build_os@
1124+build_vendor = @build_vendor@
1125+builddir = @builddir@
1126+datadir = @datadir@
1127+datarootdir = @datarootdir@
1128+docdir = @docdir@
1129+dvidir = @dvidir@
1130+exec_prefix = @exec_prefix@
1131+has_pkg_config = @has_pkg_config@
1132+host = @host@
1133+host_alias = @host_alias@
1134+host_cpu = @host_cpu@
1135+host_os = @host_os@
1136+host_vendor = @host_vendor@
1137+htmldir = @htmldir@
1138+includedir = @includedir@
1139+infodir = @infodir@
1140+install_sh = @install_sh@
1141+javadir = @javadir@
1142+libapol_jswig_soname = @libapol_jswig_soname@
1143+libapol_pyswig_soname = @libapol_pyswig_soname@
1144+libapol_soname = @libapol_soname@
1145+libapol_soversion = @libapol_soversion@
1146+libapol_tswig_soname = @libapol_tswig_soname@
1147+libapol_version = @libapol_version@
1148+libdir = @libdir@
1149+libexecdir = @libexecdir@
1150+libpoldiff_jswig_soname = @libpoldiff_jswig_soname@
1151+libpoldiff_pyswig_soname = @libpoldiff_pyswig_soname@
1152+libpoldiff_soname = @libpoldiff_soname@
1153+libpoldiff_soversion = @libpoldiff_soversion@
1154+libpoldiff_tswig_soname = @libpoldiff_tswig_soname@
1155+libpoldiff_version = @libpoldiff_version@
1156+libqpol_jswig_soname = @libqpol_jswig_soname@
1157+libqpol_pyswig_soname = @libqpol_pyswig_soname@
1158+libqpol_soname = @libqpol_soname@
1159+libqpol_soversion = @libqpol_soversion@
1160+libqpol_tswig_soname = @libqpol_tswig_soname@
1161+libqpol_version = @libqpol_version@
1162+libseaudit_jswig_soname = @libseaudit_jswig_soname@
1163+libseaudit_pyswig_soname = @libseaudit_pyswig_soname@
1164+libseaudit_soname = @libseaudit_soname@
1165+libseaudit_soversion = @libseaudit_soversion@
1166+libseaudit_tswig_soname = @libseaudit_tswig_soname@
1167+libseaudit_version = @libseaudit_version@
1168+libsefs_jswig_soname = @libsefs_jswig_soname@
1169+libsefs_pyswig_soname = @libsefs_pyswig_soname@
1170+libsefs_soname = @libsefs_soname@
1171+libsefs_soversion = @libsefs_soversion@
1172+libsefs_tswig_soname = @libsefs_tswig_soname@
1173+libsefs_version = @libsefs_version@
1174+localedir = @localedir@
1175+localstatedir = @localstatedir@
1176+lt_ECHO = @lt_ECHO@
1177+mandir = @mandir@
1178+mkdir_p = @mkdir_p@
1179+oldincludedir = @oldincludedir@
1180+pdfdir = @pdfdir@
1181+pkgpyexecdir = @pkgpyexecdir@
1182+pkgpythondir = @pkgpythondir@
1183+prefix = @prefix@
1184+profile_install_dir = @profile_install_dir@
1185+program_transform_name = @program_transform_name@
1186+psdir = @psdir@
1187+pyexecdir = @pyexecdir@
1188+pythondir = @pythondir@
1189+sbindir = @sbindir@
1190+selinux_default_policy = @selinux_default_policy@
1191+selinux_policy_dir = @selinux_policy_dir@
1192+sepol_srcdir = @sepol_srcdir@
1193+setoolsdir = @setoolsdir@
1194+sharedstatedir = @sharedstatedir@
1195+srcdir = @srcdir@
1196+sysconfdir = @sysconfdir@
1197+target_alias = @target_alias@
1198+top_build_prefix = @top_build_prefix@
1199+top_builddir = @top_builddir@
1200+top_srcdir = @top_srcdir@
1201+uudecode = @uudecode@
1202+EXTRA_DIST = \
1203+ sesearch.c \
1204+ seinfo.c \
1205+ __init__.py \
1206+ setup.py \
1207+ $(NULL)
1208+
1209+AM_CFLAGS = @DEBUGCFLAGS@ @WARNCFLAGS@ @PROFILECFLAGS@ @SELINUX_CFLAGS@ \
1210+ @QPOL_CFLAGS@ @APOL_CFLAGS@
1211+
1212+AM_CXXFLAGS = @DEBUGCXXFLAGS@ @WARNCXXFLAGS@ @PROFILECFLAGS@ @SELINUX_CFLAGS@ \
1213+ @QPOL_CFLAGS@ @APOL_CFLAGS@ @SEFS_CFLAGS@
1214+
1215+AM_LDFLAGS = @DEBUGLDFLAGS@ @WARNLDFLAGS@ @PROFILELDFLAGS@
1216+LDADD = @SELINUX_LIB_FLAG@ @APOL_LIB_FLAG@ @QPOL_LIB_FLAG@
1217+DEPENDENCIES = $(top_builddir)/libapol/src/libapol.so $(top_builddir)/libqpol/src/libqpol.so
1218+seinfo_SOURCES = seinfo.c
1219+sesearch_SOURCES = sesearch.c
1220+all: all-am
1221+
1222+.SUFFIXES:
1223+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
1224+ @for dep in $?; do \
1225+ case '$(am__configure_deps)' in \
1226+ *$$dep*) \
1227+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
1228+ && { if test -f $@; then exit 0; else break; fi; }; \
1229+ exit 1;; \
1230+ esac; \
1231+ done; \
1232+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu python/setools/Makefile'; \
1233+ $(am__cd) $(top_srcdir) && \
1234+ $(AUTOMAKE) --gnu python/setools/Makefile
1235+.PRECIOUS: Makefile
1236+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
1237+ @case '$?' in \
1238+ *config.status*) \
1239+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
1240+ *) \
1241+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
1242+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
1243+ esac;
1244+
1245+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
1246+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
1247+
1248+$(top_srcdir)/configure: $(am__configure_deps)
1249+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
1250+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
1251+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
1252+$(am__aclocal_m4_deps):
1253+
1254+mostlyclean-libtool:
1255+ -rm -f *.lo
1256+
1257+clean-libtool:
1258+ -rm -rf .libs _libs
1259+tags: TAGS
1260+TAGS:
1261+
1262+ctags: CTAGS
1263+CTAGS:
1264+
1265+
1266+distdir: $(DISTFILES)
1267+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
1268+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
1269+ list='$(DISTFILES)'; \
1270+ dist_files=`for file in $$list; do echo $$file; done | \
1271+ sed -e "s|^$$srcdirstrip/||;t" \
1272+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
1273+ case $$dist_files in \
1274+ */*) $(MKDIR_P) `echo "$$dist_files" | \
1275+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
1276+ sort -u` ;; \
1277+ esac; \
1278+ for file in $$dist_files; do \
1279+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
1280+ if test -d $$d/$$file; then \
1281+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
1282+ if test -d "$(distdir)/$$file"; then \
1283+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
1284+ fi; \
1285+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
1286+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
1287+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
1288+ fi; \
1289+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
1290+ else \
1291+ test -f "$(distdir)/$$file" \
1292+ || cp -p $$d/$$file "$(distdir)/$$file" \
1293+ || exit 1; \
1294+ fi; \
1295+ done
1296+check-am: all-am
1297+check: check-am
1298+all-am: Makefile
1299+installdirs:
1300+install: install-am
1301+install-exec: install-exec-am
1302+install-data: install-data-am
1303+uninstall: uninstall-am
1304+
1305+install-am: all-am
1306+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
1307+
1308+installcheck: installcheck-am
1309+install-strip:
1310+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
1311+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
1312+ `test -z '$(STRIP)' || \
1313+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
1314+mostlyclean-generic:
1315+
1316+clean-generic:
1317+
1318+distclean-generic:
1319+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
1320+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
1321+
1322+maintainer-clean-generic:
1323+ @echo "This command is intended for maintainers to use"
1324+ @echo "it deletes files that may require special tools to rebuild."
1325+clean: clean-am
1326+
1327+clean-am: clean-generic clean-libtool clean-local mostlyclean-am
1328+
1329+distclean: distclean-am
1330+ -rm -f Makefile
1331+distclean-am: clean-am distclean-generic
1332+
1333+dvi: dvi-am
1334+
1335+dvi-am:
1336+
1337+html: html-am
1338+
1339+html-am:
1340+
1341+info: info-am
1342+
1343+info-am:
1344+
1345+install-data-am:
1346+
1347+install-dvi: install-dvi-am
1348+
1349+install-dvi-am:
1350+
1351+install-exec-am:
1352+ @$(NORMAL_INSTALL)
1353+ $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
1354+install-html: install-html-am
1355+
1356+install-html-am:
1357+
1358+install-info: install-info-am
1359+
1360+install-info-am:
1361+
1362+install-man:
1363+
1364+install-pdf: install-pdf-am
1365+
1366+install-pdf-am:
1367+
1368+install-ps: install-ps-am
1369+
1370+install-ps-am:
1371+
1372+installcheck-am:
1373+
1374+maintainer-clean: maintainer-clean-am
1375+ -rm -f Makefile
1376+maintainer-clean-am: distclean-am maintainer-clean-generic
1377+
1378+mostlyclean: mostlyclean-am
1379+
1380+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
1381+
1382+pdf: pdf-am
1383+
1384+pdf-am:
1385+
1386+ps: ps-am
1387+
1388+ps-am:
1389+
1390+uninstall-am:
1391+ @$(NORMAL_INSTALL)
1392+ $(MAKE) $(AM_MAKEFLAGS) uninstall-hook
1393+.MAKE: install-am install-exec-am install-strip uninstall-am
1394+
1395+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
1396+ clean-local distclean distclean-generic distclean-libtool \
1397+ distdir dvi dvi-am html html-am info info-am install \
1398+ install-am install-data install-data-am install-dvi \
1399+ install-dvi-am install-exec install-exec-am install-exec-hook \
1400+ install-html install-html-am install-info install-info-am \
1401+ install-man install-pdf install-pdf-am install-ps \
1402+ install-ps-am install-strip installcheck installcheck-am \
1403+ installdirs maintainer-clean maintainer-clean-generic \
1404+ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
1405+ ps ps-am uninstall uninstall-am uninstall-hook
1406+
1407+all-am: python-build
1408+
1409+python-build: sesearch.c seinfo.c
1410+ @mkdir -p setools
1411+ @cp __init__.py setools
1412+ LIBS="$(QPOL_LIB_FLAG) $(APOL_LIB_FLAG)" INCLUDES="$(QPOL_CFLAGS) $(APOL_CFLAGS)" $(PYTHON) setup.py build
1413+
1414+install-exec-hook:
1415+ $(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
1416+
1417+uninstall-hook:
1418+ $(PYTHON) setup.py uninstall `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
1419+
1420+clean-local:
1421+ $(PYTHON) setup.py clean -a
1422+ rm -f *~
1423+
1424+# Tell versions [3.59,3.63) of GNU make to not export all variables.
1425+# Otherwise a system limit (for SysV at least) may be exceeded.
1426+.NOEXPORT:
1427diff --git a/python/setools/__init__.py b/python/setools/__init__.py
1428new file mode 100644
1429index 0000000..6f075c4
1430--- /dev/null
1431+++ b/python/setools/__init__.py
1432@@ -0,0 +1,50 @@
1433+#!/usr/bin/env python
1434+
1435+# Author: Thomas Liu <tliu@redhat.com>
1436+
1437+import _sesearch
1438+import _seinfo
1439+import types
1440+
1441+TYPE = _seinfo.TYPE
1442+ROLE = _seinfo.ROLE
1443+ATTRIBUTE = _seinfo.ATTRIBUTE
1444+PORT = _seinfo.PORT
1445+USER = _seinfo.USER
1446+
1447+ALLOW = 'allow'
1448+AUDITALLOW = 'auditallow'
1449+NEVERALLOW = 'neverallow'
1450+DONTAUDIT = 'dontaudit'
1451+SCONTEXT = 'scontext'
1452+TCONTEXT = 'tcontext'
1453+PERMS = 'permlist'
1454+CLASS = 'class'
1455+
1456+def sesearch(types, info):
1457+ valid_types = [ALLOW, AUDITALLOW, NEVERALLOW, DONTAUDIT]
1458+ for type in types:
1459+ if type not in valid_types:
1460+ raise ValueError("Type has to be in %s" % valid_types)
1461+ info[type] = True
1462+
1463+ perms = []
1464+ if PERMS in info:
1465+ perms = info[PERMS]
1466+ info[PERMS] = ",".join(info[PERMS])
1467+
1468+
1469+ dict_list = _sesearch.sesearch(info)
1470+ if dict_list and len(perms) != 0:
1471+ dict_list = filter(lambda x: dict_has_perms(x, perms), dict_list)
1472+ return dict_list
1473+
1474+def dict_has_perms(dict, perms):
1475+ for perm in perms:
1476+ if perm not in dict[PERMS]:
1477+ return False
1478+ return True
1479+
1480+def seinfo(setype, name=None):
1481+ dict_list = _seinfo.seinfo(setype, name)
1482+ return dict_list
1483diff --git a/python/setools/seinfo.c b/python/setools/seinfo.c
1484new file mode 100644
1485index 0000000..211930a
1486--- /dev/null
1487+++ b/python/setools/seinfo.c
1488@@ -0,0 +1,769 @@
1489+/**
1490+ * @file
1491+ * Command line tool to search TE rules.
1492+ *
1493+ * @author Frank Mayer mayerf@tresys.com
1494+ * @author Jeremy A. Mowery jmowery@tresys.com
1495+ * @author Paul Rosenfeld prosenfeld@tresys.com
1496+ * @author Thomas Liu <tliu@redhat.com>
1497+ * @author Dan Walsh <dwalsh@redhat.com>
1498+ *
1499+ * Copyright (C) 2003-2008 Tresys Technology, LLC
1500+ *
1501+ * This program is free software; you can redistribute it and/or modify
1502+ * it under the terms of the GNU General Public License as published by
1503+ * the Free Software Foundation; either version 2 of the License, or
1504+ * (at your option) any later version.
1505+ *
1506+ * This program is distributed in the hope that it will be useful,
1507+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1508+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1509+ * GNU General Public License for more details.
1510+ *
1511+ * You should have received a copy of the GNU General Public License
1512+ * along with this program; if not, write to the Free Software
1513+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1514+ */
1515+
1516+/**
1517+ * This is a modified version of seinfo to be used as part of a library for
1518+ * Python bindings.
1519+ */
1520+
1521+#include "Python.h"
1522+
1523+/* libapol */
1524+#include <apol/policy.h>
1525+#include <apol/policy-query.h>
1526+#include <apol/render.h>
1527+#include <apol/util.h>
1528+#include <apol/vector.h>
1529+
1530+/* libqpol */
1531+#include <qpol/policy.h>
1532+#include <qpol/util.h>
1533+
1534+/* other */
1535+#include <errno.h>
1536+#include <stdlib.h>
1537+#include <stdio.h>
1538+#include <string.h>
1539+#include <assert.h>
1540+
1541+#define COPYRIGHT_INFO "Copyright (C) 2003-2007 Tresys Technology, LLC"
1542+static char *policy_file = NULL;
1543+
1544+enum input
1545+{
1546+ TYPE, ATTRIBUTE, ROLE, USER, PORT,
1547+};
1548+
1549+/**
1550+ * Gets a textual representation of an attribute, and
1551+ * all of that attribute's types.
1552+ *
1553+ * @param type_datum Reference to sepol type_datum
1554+ * @param policydb Reference to a policy
1555+ */
1556+static PyObject* get_attr(const qpol_type_t * type_datum, const apol_policy_t * policydb)
1557+{
1558+ int retval = -1;
1559+ PyObject *dict = PyDict_New();
1560+ const qpol_type_t *attr_datum = NULL;
1561+ qpol_iterator_t *iter = NULL;
1562+ const char *attr_name = NULL, *type_name = NULL;
1563+ qpol_policy_t *q = apol_policy_get_qpol(policydb);
1564+ unsigned char isattr;
1565+
1566+ if (qpol_type_get_name(q, type_datum, &attr_name))
1567+ goto cleanup;
1568+ PyObject *obj = PyString_FromString(attr_name);
1569+ PyDict_SetItemString(dict, "name", obj);
1570+ Py_DECREF(obj);
1571+
1572+ /* get an iterator over all types this attribute has */
1573+ if (qpol_type_get_isattr(q, type_datum, &isattr))
1574+ goto cleanup;
1575+ if (isattr) { /* sanity check */
1576+ if (qpol_type_get_type_iter(q, type_datum, &iter))
1577+ goto cleanup;
1578+ PyObject *list = PyList_New(0);
1579+ for (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {
1580+ if (qpol_iterator_get_item(iter, (void **)&attr_datum))
1581+ goto cleanup;
1582+ if (qpol_type_get_name(q, attr_datum, &type_name))
1583+ goto cleanup;
1584+ PyObject *obj = PyString_FromString(type_name);
1585+ PyList_Append(list, obj);
1586+ Py_DECREF(obj);
1587+ }
1588+ qpol_iterator_destroy(&iter);
1589+ PyDict_SetItemString(dict, "types", list);
1590+ Py_DECREF(list);
1591+ } else /* this should never happen */
1592+ goto cleanup;
1593+
1594+ retval = 0;
1595+cleanup:
1596+ qpol_iterator_destroy(&iter);
1597+ if (retval) {
1598+ Py_DECREF(dict);
1599+ return NULL;
1600+ }
1601+ return dict;
1602+}
1603+
1604+/**
1605+ * Gets statistics regarding a policy's attributes.
1606+ * If this function is given a name, it will attempt to
1607+ * get statistics about a particular attribute; otherwise
1608+ * the function gets statistics about all of the policy's
1609+ * attributes.
1610+ *
1611+ * @param name Reference to an attribute's name; if NULL,
1612+ * all object classes will be considered
1613+ * @param policydb Reference to a policy
1614+ *
1615+ * @return 0 on success, < 0 on error.
1616+ */
1617+static PyObject* get_attribs(const char *name, const apol_policy_t * policydb)
1618+{
1619+ int retval = -1;
1620+ PyObject *list = PyList_New(0);
1621+ apol_attr_query_t *attr_query = NULL;
1622+ apol_vector_t *v = NULL;
1623+ const qpol_type_t *type_datum = NULL;
1624+ size_t n_attrs, i;
1625+
1626+ /* we are only getting information about 1 attribute */
1627+ if (name != NULL) {
1628+ attr_query = apol_attr_query_create();
1629+ if (!attr_query)
1630+ goto cleanup;
1631+ if (apol_attr_query_set_attr(policydb, attr_query, name))
1632+ goto cleanup;
1633+ if (apol_attr_get_by_query(policydb, attr_query, &v))
1634+ goto cleanup;
1635+ apol_attr_query_destroy(&attr_query);
1636+ if (apol_vector_get_size(v) == 0) {
1637+ apol_vector_destroy(&v);
1638+ errno = EINVAL;
1639+ goto cleanup;
1640+ }
1641+
1642+ type_datum = apol_vector_get_element(v, (size_t) 0);
1643+ PyObject *obj = get_attr(type_datum, policydb);
1644+ PyList_Append(list, obj);
1645+ Py_DECREF(obj);
1646+ } else {
1647+ attr_query = apol_attr_query_create();
1648+ if (!attr_query)
1649+ goto cleanup;
1650+ if (apol_attr_get_by_query(policydb, attr_query, &v))
1651+ goto cleanup;
1652+ apol_attr_query_destroy(&attr_query);
1653+ n_attrs = apol_vector_get_size(v);
1654+
1655+ for (i = 0; i < n_attrs; i++) {
1656+ /* get qpol_type_t* item from vector */
1657+ type_datum = (qpol_type_t *) apol_vector_get_element(v, (size_t) i);
1658+ if (!type_datum)
1659+ goto cleanup;
1660+ PyObject *obj = get_attr(type_datum, policydb);
1661+ PyList_Append(list, obj);
1662+ Py_DECREF(obj);
1663+ }
1664+ }
1665+ apol_vector_destroy(&v);
1666+
1667+ retval = 0;
1668+ cleanup:
1669+ apol_attr_query_destroy(&attr_query);
1670+ apol_vector_destroy(&v);
1671+ if (retval) {
1672+ Py_DECREF(list);
1673+ PyErr_SetString(PyExc_RuntimeError,strerror(errno));
1674+ return NULL;
1675+ }
1676+ return list;
1677+}
1678+
1679+/**
1680+ * Get a textual representation of a type, and
1681+ * all of that type's attributes.
1682+ *
1683+ * @param type_datum Reference to sepol type_datum
1684+ * @param policydb Reference to a policy
1685+ */
1686+static PyObject* get_type_attrs(const qpol_type_t * type_datum, const apol_policy_t * policydb)
1687+{
1688+ qpol_iterator_t *iter = NULL;
1689+ const char *attr_name = NULL;
1690+ const qpol_type_t *attr_datum = NULL;
1691+ qpol_policy_t *q = apol_policy_get_qpol(policydb);
1692+
1693+ if (qpol_type_get_attr_iter(q, type_datum, &iter))
1694+ goto cleanup;
1695+ PyObject *list = PyList_New(0);
1696+ for (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {
1697+ if (qpol_iterator_get_item(iter, (void **)&attr_datum))
1698+ goto cleanup;
1699+ if (qpol_type_get_name(q, attr_datum, &attr_name))
1700+ goto cleanup;
1701+ PyObject *obj = PyString_FromString(attr_name);
1702+ PyList_Append(list, obj);
1703+ Py_DECREF(obj);
1704+ }
1705+
1706+ cleanup:
1707+ qpol_iterator_destroy(&iter);
1708+ return list;
1709+}
1710+
1711+static PyObject* get_type( const qpol_type_t * type_datum, const apol_policy_t * policydb) {
1712+
1713+ PyObject *dict = PyDict_New();
1714+ qpol_policy_t *q = apol_policy_get_qpol(policydb);
1715+ const char *type_name = NULL;
1716+
1717+ unsigned char isalias, ispermissive, isattr;
1718+
1719+ if (qpol_type_get_name(q, type_datum, &type_name))
1720+ goto cleanup;
1721+ if (qpol_type_get_isalias(q, type_datum, &isalias))
1722+ goto cleanup;
1723+ if (qpol_type_get_isattr(q, type_datum, &isattr))
1724+ goto cleanup;
1725+ if (qpol_type_get_ispermissive(q, type_datum, &ispermissive))
1726+ goto cleanup;
1727+
1728+ PyObject *obj = PyString_FromString(type_name);
1729+ PyDict_SetItemString(dict, "name", obj);
1730+ Py_DECREF(obj);
1731+ obj = PyBool_FromLong(ispermissive);
1732+ PyDict_SetItemString(dict, "permissive", obj);
1733+ Py_DECREF(obj);
1734+ if (!isattr && !isalias) {
1735+ obj = get_type_attrs(type_datum, policydb);
1736+ PyDict_SetItemString(dict, "attributes", obj);
1737+ Py_DECREF(obj);
1738+ }
1739+ return dict;
1740+cleanup:
1741+ Py_DECREF(dict);
1742+ return NULL;
1743+}
1744+
1745+/**
1746+ * Gets a textual representation of a user, and
1747+ * all of that user's roles.
1748+ *
1749+ * @param type_datum Reference to sepol type_datum
1750+ * @param policydb Reference to a policy
1751+ * roles
1752+ */
1753+static PyObject* get_user(const qpol_user_t * user_datum, const apol_policy_t * policydb)
1754+{
1755+ PyObject *dict = NULL;
1756+ const qpol_role_t *role_datum = NULL;
1757+ qpol_iterator_t *iter = NULL;
1758+ const qpol_mls_range_t *range = NULL;
1759+ const qpol_mls_level_t *dflt_level = NULL;
1760+ apol_mls_level_t *ap_lvl = NULL;
1761+ apol_mls_range_t *ap_range = NULL;
1762+ qpol_policy_t *q = apol_policy_get_qpol(policydb);
1763+ char *tmp;
1764+ const char *user_name, *role_name;
1765+
1766+ if (qpol_user_get_name(q, user_datum, &user_name))
1767+ goto cleanup;
1768+
1769+ dict = PyDict_New();
1770+ PyObject *obj = PyString_FromString(user_name);
1771+ PyDict_SetItemString(dict, "name", obj);
1772+ Py_DECREF(obj);
1773+
1774+ if (qpol_policy_has_capability(q, QPOL_CAP_MLS)) {
1775+ if (qpol_user_get_dfltlevel(q, user_datum, &dflt_level))
1776+ goto cleanup;
1777+ ap_lvl = apol_mls_level_create_from_qpol_mls_level(policydb, dflt_level);
1778+ tmp = apol_mls_level_render(policydb, ap_lvl);
1779+ if (!tmp)
1780+ goto cleanup;
1781+ obj = PyString_FromString(tmp);
1782+ PyDict_SetItemString(dict, "level", obj);
1783+ Py_DECREF(obj);
1784+ free(tmp);
1785+ /* print default range */
1786+ if (qpol_user_get_range(q, user_datum, &range))
1787+ goto cleanup;
1788+ ap_range = apol_mls_range_create_from_qpol_mls_range(policydb, range);
1789+ tmp = apol_mls_range_render(policydb, ap_range);
1790+ if (!tmp)
1791+ goto cleanup;
1792+ obj = PyString_FromString(tmp);
1793+ PyDict_SetItemString(dict, "range", obj);
1794+ Py_DECREF(obj);
1795+ free(tmp);
1796+ }
1797+
1798+ if (qpol_user_get_role_iter(q, user_datum, &iter))
1799+ goto cleanup;
1800+ PyObject *list = PyList_New(0);
1801+ for (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {
1802+ if (qpol_iterator_get_item(iter, (void **)&role_datum)) {
1803+ Py_DECREF(list);
1804+ goto cleanup;
1805+ }
1806+ if (qpol_role_get_name(q, role_datum, &role_name)) {
1807+ Py_DECREF(list);
1808+ goto cleanup;
1809+ }
1810+ PyObject *obj = PyString_FromString(role_name);
1811+ PyList_Append(list, obj);
1812+ Py_DECREF(obj);
1813+ }
1814+ PyDict_SetItemString(dict, "roles", list);
1815+ Py_DECREF(list);
1816+
1817+cleanup:
1818+ qpol_iterator_destroy(&iter);
1819+ apol_mls_level_destroy(&ap_lvl);
1820+ apol_mls_range_destroy(&ap_range);
1821+ return dict;
1822+}
1823+
1824+/**
1825+ * Gets statistics regarding a policy's users.
1826+ * If this function is given a name, it will attempt to
1827+ * get statistics about a particular user; otherwise
1828+ * the function gets statistics about all of the policy's
1829+ * users.
1830+ *
1831+ * @param name Reference to a user's name; if NULL,
1832+ * all users will be considered
1833+ * @param policydb Reference to a policy
1834+ *
1835+ * @return 0 on success, < 0 on error.
1836+ */
1837+static PyObject* get_users(const char *name, const apol_policy_t * policydb)
1838+{
1839+ int retval = -1;
1840+ PyObject *list = PyList_New(0);
1841+ qpol_iterator_t *iter = NULL;
1842+ const qpol_user_t *user_datum = NULL;
1843+ qpol_policy_t *q = apol_policy_get_qpol(policydb);
1844+
1845+ if (name != NULL) {
1846+ if (qpol_policy_get_user_by_name(q, name, &user_datum)) {
1847+ errno = EINVAL;
1848+ goto cleanup;
1849+ }
1850+ PyObject *obj = get_user(user_datum, policydb);
1851+ PyList_Append(list, obj);
1852+ Py_DECREF(obj);
1853+ } else {
1854+ if (qpol_policy_get_user_iter(q, &iter))
1855+ goto cleanup;
1856+
1857+ for (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {
1858+ if (qpol_iterator_get_item(iter, (void **)&user_datum))
1859+ goto cleanup;
1860+ PyObject *obj = get_user(user_datum, policydb);
1861+ PyList_Append(list, obj);
1862+ Py_DECREF(obj);
1863+ }
1864+ qpol_iterator_destroy(&iter);
1865+ }
1866+
1867+ retval = 0;
1868+ cleanup:
1869+ qpol_iterator_destroy(&iter);
1870+ if (retval) {
1871+ Py_DECREF(list);
1872+ PyErr_SetString(PyExc_RuntimeError,strerror(errno));
1873+ return NULL;
1874+ }
1875+ return list;
1876+}
1877+
1878+/**
1879+ * get a textual representation of a role, and
1880+ * all of that role's types.
1881+ *
1882+ * @param type_datum Reference to sepol type_datum
1883+ * @param policydb Reference to a policy
1884+ * types
1885+ */
1886+static PyObject* get_role(const qpol_role_t * role_datum, const apol_policy_t * policydb)
1887+{
1888+ int retval = -1;
1889+ PyObject *dict = PyDict_New();
1890+ const char *role_name = NULL, *type_name = NULL;
1891+ const qpol_role_t *dom_datum = NULL;
1892+ const qpol_type_t *type_datum = NULL;
1893+ qpol_iterator_t *iter = NULL;
1894+ qpol_policy_t *q = apol_policy_get_qpol(policydb);
1895+ size_t n_dom = 0, n_types = 0;
1896+
1897+ if (qpol_role_get_name(q, role_datum, &role_name))
1898+ goto cleanup;
1899+
1900+ PyObject *obj = PyString_FromString(role_name);
1901+ PyDict_SetItemString(dict, "name", obj);
1902+ Py_DECREF(obj);
1903+
1904+ if (qpol_role_get_dominate_iter(q, role_datum, &iter))
1905+ goto cleanup;
1906+ if (qpol_iterator_get_size(iter, &n_dom))
1907+ goto cleanup;
1908+ if ((int)n_dom > 0) {
1909+ PyObject *list = PyList_New(0);
1910+ for (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {
1911+ if (qpol_iterator_get_item(iter, (void **)&dom_datum))
1912+ goto cleanup;
1913+ if (qpol_role_get_name(q, dom_datum, &role_name))
1914+ goto cleanup;
1915+ PyObject *obj = PyString_FromString(role_name);
1916+ PyList_Append(list, obj);
1917+ Py_DECREF(obj);
1918+ }
1919+ PyDict_SetItemString(dict, "dominate", list);
1920+ Py_DECREF(list);
1921+ }
1922+ qpol_iterator_destroy(&iter);
1923+
1924+ if (qpol_role_get_type_iter(q, role_datum, &iter))
1925+ goto cleanup;
1926+ if (qpol_iterator_get_size(iter, &n_types))
1927+ goto cleanup;
1928+ if ((int)n_types > 0) {
1929+ PyObject *list = PyList_New(0);
1930+ /* print types */
1931+ for (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {
1932+ if (qpol_iterator_get_item(iter, (void **)&type_datum))
1933+ goto cleanup;
1934+ if (qpol_type_get_name(q, type_datum, &type_name))
1935+ goto cleanup;
1936+ PyObject *obj = PyString_FromString(type_name);
1937+ PyList_Append(list, obj);
1938+ Py_DECREF(obj);
1939+ }
1940+ PyDict_SetItemString(dict, "types", list);
1941+ Py_DECREF(list);
1942+ }
1943+
1944+ retval = 0;
1945+cleanup:
1946+ qpol_iterator_destroy(&iter);
1947+ if (retval) {
1948+ Py_DECREF(dict);
1949+ PyErr_SetString(PyExc_RuntimeError,strerror(errno));
1950+ return NULL;
1951+ }
1952+ return dict;
1953+}
1954+
1955+/**
1956+ * Get statistics regarding a policy's ports.
1957+ * If this function is given a name, it will attempt to
1958+ * get statistics about a particular port; otherwise
1959+ * the function get statistics about all of the policy's ports.
1960+ *
1961+ * @param name Reference to an port's name; if NULL,
1962+ * all ports will be considered
1963+ * @param policydb Reference to a policy
1964+ *
1965+ * @return 0 on success, < 0 on error.
1966+ */
1967+static PyObject* get_ports(const char *num, const apol_policy_t * policydb)
1968+{
1969+ PyObject *list = PyList_New(0);
1970+ int retval = -1;
1971+ const qpol_portcon_t *portcon = NULL;
1972+ qpol_iterator_t *iter = NULL;
1973+ uint16_t low_port, high_port;
1974+ uint8_t ocon_proto;
1975+ qpol_policy_t *q = apol_policy_get_qpol(policydb);
1976+ const qpol_context_t *ctxt = NULL;
1977+ const char *proto_str;
1978+ PyObject *dict;
1979+ const char *type = NULL;
1980+ const apol_mls_range_t *range = NULL;
1981+ char *range_str = NULL;
1982+ PyObject *obj = NULL;
1983+ apol_context_t *c = NULL;
1984+
1985+ if (qpol_policy_get_portcon_iter(q, &iter))
1986+ goto cleanup;
1987+
1988+ for (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {
1989+ if (qpol_iterator_get_item(iter, (void **)&portcon))
1990+ goto cleanup;
1991+ if (qpol_portcon_get_low_port(q, portcon, &low_port))
1992+ goto cleanup;
1993+ if (qpol_portcon_get_high_port(q, portcon, &high_port))
1994+ goto cleanup;
1995+ if (qpol_portcon_get_protocol(q, portcon, &ocon_proto))
1996+ goto cleanup;
1997+ if (num) {
1998+ if (atoi(num) < low_port || atoi(num) > high_port)
1999+ continue;
2000+ }
2001+
2002+ if ((ocon_proto != IPPROTO_TCP) &&
2003+ (ocon_proto != IPPROTO_UDP))
2004+ goto cleanup;
2005+
2006+ if (qpol_portcon_get_context(q, portcon, &ctxt)) {
2007+ PyErr_SetString(PyExc_RuntimeError, "Could not get for port context.");
2008+ goto cleanup;
2009+ }
2010+
2011+ if ((proto_str = apol_protocol_to_str(ocon_proto)) == NULL) {
2012+ PyErr_SetString(PyExc_RuntimeError, "Invalid protocol for port");
2013+ goto cleanup;
2014+ }
2015+
2016+ if ((c = apol_context_create_from_qpol_context(policydb, ctxt)) == NULL) {
2017+ goto cleanup;
2018+ }
2019+
2020+ if((type = apol_context_get_type(c)) == NULL) {
2021+ apol_context_destroy(&c);
2022+ goto cleanup;
2023+ }
2024+
2025+ dict = PyDict_New();
2026+ obj = PyString_FromString(type);
2027+ PyDict_SetItemString(dict, "type", obj);
2028+ Py_DECREF(obj);
2029+
2030+ if((range = apol_context_get_range(c)) == NULL) {
2031+ goto cleanup;
2032+ }
2033+
2034+ range_str = apol_mls_range_render(policydb, range);
2035+ if (range_str == NULL) {
2036+ goto cleanup;
2037+ }
2038+ obj = PyString_FromString(range_str);
2039+ PyDict_SetItemString(dict, "range", obj);
2040+ Py_DECREF(obj);
2041+
2042+ obj = PyString_FromString(proto_str);
2043+ PyDict_SetItemString(dict, "protocol", obj);
2044+ Py_DECREF(obj);
2045+
2046+ obj = PyInt_FromLong(high_port);
2047+ PyDict_SetItemString(dict, "high", obj);
2048+ Py_DECREF(obj);
2049+
2050+ obj = PyInt_FromLong(low_port);
2051+ PyDict_SetItemString(dict, "low", obj);
2052+ Py_DECREF(obj);
2053+
2054+ PyList_Append(list, dict);
2055+ Py_DECREF(dict);
2056+ }
2057+ retval = 0;
2058+ cleanup:
2059+ free(range_str);
2060+ apol_context_destroy(&c);
2061+ qpol_iterator_destroy(&iter);
2062+
2063+ if (retval) {
2064+ Py_DECREF(list);
2065+ PyErr_SetString(PyExc_RuntimeError,strerror(errno));
2066+ return NULL;
2067+ }
2068+ return list;
2069+}
2070+
2071+/**
2072+ * Get statistics regarding a policy's roles.
2073+ * If this function is given a name, it will attempt to
2074+ * get statistics about a particular role; otherwise
2075+ * the function get statistics about all of the policy's roles.
2076+ *
2077+ * @param name Reference to an role's name; if NULL,
2078+ * all roles will be considered
2079+ * @param policydb Reference to a policy
2080+ *
2081+ * @return 0 on success, < 0 on error.
2082+ */
2083+static PyObject* get_roles(const char *name, const apol_policy_t * policydb)
2084+{
2085+ int retval = -1;
2086+ PyObject *list = PyList_New(0);
2087+ const qpol_role_t *role_datum = NULL;
2088+ qpol_iterator_t *iter = NULL;
2089+ qpol_policy_t *q = apol_policy_get_qpol(policydb);
2090+
2091+ if (name != NULL) {
2092+ if (qpol_policy_get_role_by_name(q, name, &role_datum)) {
2093+ errno = EINVAL;
2094+ goto cleanup;
2095+ }
2096+ PyObject *obj = get_role(role_datum, policydb);
2097+ PyList_Append(list, obj);
2098+ Py_DECREF(obj);
2099+ } else {
2100+ if (qpol_policy_get_role_iter(q, &iter))
2101+ goto cleanup;
2102+
2103+ for (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {
2104+ if (qpol_iterator_get_item(iter, (void **)&role_datum))
2105+ goto cleanup;
2106+ PyObject *obj = get_role(role_datum, policydb);
2107+ PyList_Append(list, obj);
2108+ Py_DECREF(obj);
2109+ }
2110+ qpol_iterator_destroy(&iter);
2111+ }
2112+
2113+ retval = 0;
2114+ cleanup:
2115+ qpol_iterator_destroy(&iter);
2116+ if (retval) {
2117+ Py_DECREF(list);
2118+ PyErr_SetString(PyExc_RuntimeError,strerror(errno));
2119+ return NULL;
2120+ }
2121+ return list;
2122+}
2123+
2124+/**
2125+ * Get statistics regarding a policy's types.
2126+ * If this function is given a name, it will attempt to
2127+ * print statistics about a particular type; otherwise
2128+ * the function prints statistics about all of the policy's types.
2129+ *
2130+ * @param name Reference to a type's name; if NULL,
2131+ * all object classes will be considered
2132+ * @param policydb Reference to a policy
2133+ *
2134+ * @return 0 on success, < 0 on error.
2135+ */
2136+static PyObject* get_types(const char *name, const apol_policy_t * policydb)
2137+{
2138+ int retval = -1;
2139+ PyObject *list = PyList_New(0);
2140+ const qpol_type_t *type_datum = NULL;
2141+ qpol_iterator_t *iter = NULL;
2142+ qpol_policy_t *q = apol_policy_get_qpol(policydb);
2143+
2144+ /* if name was provided, only print that name */
2145+ if (name != NULL) {
2146+ if (qpol_policy_get_type_by_name(q, name, &type_datum)) {
2147+ errno = EINVAL;
2148+ goto cleanup;
2149+ }
2150+ PyObject *obj = get_type(type_datum, policydb);
2151+ PyList_Append(list, obj);
2152+ Py_DECREF(obj);
2153+ } else {
2154+ if (qpol_policy_get_type_iter(q, &iter))
2155+ goto cleanup;
2156+ /* Print all type names */
2157+ for (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {
2158+ if (qpol_iterator_get_item(iter, (void **)&type_datum))
2159+ goto cleanup;
2160+ PyObject *obj = get_type(type_datum, policydb);
2161+ PyList_Append(list, obj);
2162+ Py_DECREF(obj);
2163+ }
2164+ }
2165+ retval = 0;
2166+cleanup:
2167+ qpol_iterator_destroy(&iter);
2168+ if (retval) {
2169+ Py_DECREF(list);
2170+ PyErr_SetString(PyExc_RuntimeError,strerror(errno));
2171+ return NULL;
2172+ }
2173+ return list;
2174+}
2175+
2176+PyObject* seinfo(int type, const char *name)
2177+{
2178+ int rt = -1;
2179+
2180+ apol_policy_t *policydb = NULL;
2181+ apol_policy_path_t *pol_path = NULL;
2182+ apol_vector_t *mod_paths = NULL;
2183+ apol_policy_path_type_e path_type = APOL_POLICY_PATH_TYPE_MONOLITHIC;
2184+ PyObject* output = NULL;
2185+
2186+ rt = qpol_default_policy_find(&policy_file);
2187+ if (rt != 0) {
2188+ PyErr_SetString(PyExc_RuntimeError,"No default policy found.");
2189+ return NULL;
2190+ }
2191+
2192+ pol_path = apol_policy_path_create(path_type, policy_file, mod_paths);
2193+ if (!pol_path) {
2194+ free(policy_file);
2195+ apol_vector_destroy(&mod_paths);
2196+ PyErr_SetString(PyExc_RuntimeError,strerror(ENOMEM));
2197+ return NULL;
2198+ }
2199+ apol_vector_destroy(&mod_paths);
2200+
2201+ int policy_load_options = 0;
2202+ policy_load_options |= QPOL_POLICY_OPTION_MATCH_SYSTEM;
2203+ policydb = apol_policy_create_from_policy_path(pol_path, policy_load_options, NULL, NULL);
2204+ if (!policydb) {
2205+ free(policy_file);
2206+ apol_policy_path_destroy(&pol_path);
2207+ PyErr_SetString(PyExc_RuntimeError,strerror(errno));
2208+ return NULL;
2209+ }
2210+ free(policy_file);
2211+
2212+ /* display requested info */
2213+ if (type == TYPE)
2214+ output = get_types(name, policydb);
2215+
2216+ if (type == ATTRIBUTE)
2217+ output = get_attribs(name, policydb);
2218+
2219+ if (type == ROLE)
2220+ output = get_roles(name, policydb);
2221+
2222+ if (type == USER)
2223+ output = get_users(name, policydb);
2224+
2225+ if (type == PORT)
2226+ output = get_ports(name, policydb);
2227+
2228+ apol_policy_destroy(&policydb);
2229+ apol_policy_path_destroy(&pol_path);
2230+ return output;
2231+}
2232+
2233+PyObject *wrap_seinfo(PyObject *self, PyObject *args){
2234+ unsigned int type;
2235+ char *name;
2236+
2237+ if (!PyArg_ParseTuple(args, "iz", &type, &name))
2238+ return NULL;
2239+
2240+ return Py_BuildValue("O",seinfo(type, name));
2241+
2242+}
2243+
2244+static PyMethodDef methods[] = {
2245+ {"seinfo", (PyCFunction) wrap_seinfo, METH_VARARGS},
2246+ {NULL, NULL, 0, NULL}
2247+};
2248+
2249+void init_seinfo(){
2250+ PyObject *m;
2251+ m = Py_InitModule("_seinfo", methods);
2252+ PyModule_AddIntConstant(m, "ATTRIBUTE", ATTRIBUTE);
2253+ PyModule_AddIntConstant(m, "PORT", PORT);
2254+ PyModule_AddIntConstant(m, "ROLE", ROLE);
2255+ PyModule_AddIntConstant(m, "TYPE", TYPE);
2256+ PyModule_AddIntConstant(m, "USER", USER);
2257+}
2258diff --git a/python/setools/sesearch.c b/python/setools/sesearch.c
2259new file mode 100644
2260index 0000000..faaf8b7
2261--- /dev/null
2262+++ b/python/setools/sesearch.c
2263@@ -0,0 +1,478 @@
2264+// Author: Thomas Liu <tliu@redhat.com>
2265+
2266+/**
2267+ * @file
2268+ * Command line tool to search TE rules.
2269+ *
2270+ * @author Frank Mayer mayerf@tresys.com
2271+ * @author Jeremy A. Mowery jmowery@tresys.com
2272+ * @author Paul Rosenfeld prosenfeld@tresys.com
2273+ * @author Thomas Liu <tliu@redhat.com>
2274+ *
2275+ * Copyright (C) 2003-2008 Tresys Technology, LLC
2276+ *
2277+ * This program is free software; you can redistribute it and/or modify
2278+ * it under the terms of the GNU General Public License as published by
2279+ * the Free Software Foundation; either version 2 of the License, or
2280+ * (at your option) any later version.
2281+ *
2282+ * This program is distributed in the hope that it will be useful,
2283+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2284+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2285+ * GNU General Public License for more details.
2286+ *
2287+ * You should have received a copy of the GNU General Public License
2288+ * along with this program; if not, write to the Free Software
2289+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2290+ */
2291+
2292+/**
2293+ * This is a modified version of sesearch to be used as part of a library for
2294+ * Python bindings.
2295+ */
2296+
2297+#include "Python.h"
2298+
2299+/* libapol */
2300+#include <apol/policy.h>
2301+#include <apol/policy-query.h>
2302+#include <apol/render.h>
2303+#include <apol/util.h>
2304+#include <apol/vector.h>
2305+
2306+/* libqpol*/
2307+#include <qpol/policy.h>
2308+#include <qpol/policy_extend.h>
2309+#include <qpol/syn_rule_query.h>
2310+#include <qpol/util.h>
2311+
2312+/* other */
2313+#include <errno.h>
2314+#include <stdlib.h>
2315+#include <stdio.h>
2316+#include <assert.h>
2317+#include <getopt.h>
2318+#include <string.h>
2319+#include <stdbool.h>
2320+
2321+#define COPYRIGHT_INFO "Copyright (C) 2003-2007 Tresys Technology, LLC"
2322+static char *policy_file = NULL;
2323+
2324+enum opt_values
2325+{
2326+ RULE_NEVERALLOW = 256, RULE_AUDIT, RULE_AUDITALLOW, RULE_DONTAUDIT,
2327+ RULE_ROLE_ALLOW, RULE_ROLE_TRANS, RULE_RANGE_TRANS, RULE_ALL,
2328+ EXPR_ROLE_SOURCE, EXPR_ROLE_TARGET
2329+};
2330+
2331+;
2332+
2333+typedef struct options
2334+{
2335+ char *src_name;
2336+ char *tgt_name;
2337+ char *src_role_name;
2338+ char *tgt_role_name;
2339+ char *class_name;
2340+ char *permlist;
2341+ char *bool_name;
2342+ apol_vector_t *class_vector;
2343+ bool all;
2344+ bool lineno;
2345+ bool semantic;
2346+ bool indirect;
2347+ bool allow;
2348+ bool nallow;
2349+ bool auditallow;
2350+ bool dontaudit;
2351+ bool type;
2352+ bool rtrans;
2353+ bool role_allow;
2354+ bool role_trans;
2355+ bool useregex;
2356+ bool show_cond;
2357+ apol_vector_t *perm_vector;
2358+} options_t;
2359+
2360+static int perform_av_query(const apol_policy_t * policy, const options_t * opt, apol_vector_t ** v)
2361+{
2362+ apol_avrule_query_t *avq = NULL;
2363+ unsigned int rules = 0;
2364+ int error = 0;
2365+ char *tmp = NULL, *tok = NULL, *s = NULL;
2366+
2367+ if (!policy || !opt || !v) {
2368+ PyErr_SetString(PyExc_RuntimeError,strerror(EINVAL));
2369+ errno = EINVAL;
2370+ return -1;
2371+ }
2372+
2373+ if (!opt->all && !opt->allow && !opt->nallow && !opt->auditallow && !opt->dontaudit) {
2374+ *v = NULL;
2375+ return 0; /* no search to do */
2376+ }
2377+
2378+ avq = apol_avrule_query_create();
2379+ if (!avq) {
2380+ PyErr_SetString(PyExc_RuntimeError,strerror(ENOMEM));
2381+ errno = ENOMEM;
2382+ return -1;
2383+ }
2384+
2385+ if (opt->allow || opt->all)
2386+ rules |= QPOL_RULE_ALLOW;
2387+ if ((opt->nallow || opt->all) && qpol_policy_has_capability(apol_policy_get_qpol(policy), QPOL_CAP_NEVERALLOW))
2388+ rules |= QPOL_RULE_NEVERALLOW;
2389+ if (opt->auditallow || opt->all)
2390+ rules |= QPOL_RULE_AUDITALLOW;
2391+ if (opt->dontaudit || opt->all)
2392+ rules |= QPOL_RULE_DONTAUDIT;
2393+ apol_avrule_query_set_rules(policy, avq, rules);
2394+ apol_avrule_query_set_regex(policy, avq, opt->useregex);
2395+ if (opt->src_name)
2396+ apol_avrule_query_set_source(policy, avq, opt->src_name, opt->indirect);
2397+ if (opt->tgt_name)
2398+ apol_avrule_query_set_target(policy, avq, opt->tgt_name, opt->indirect);
2399+ if (opt->bool_name)
2400+ apol_avrule_query_set_bool(policy, avq, opt->bool_name);
2401+ if (opt->class_name) {
2402+ if (opt->class_vector == NULL) {
2403+ if (apol_avrule_query_append_class(policy, avq, opt->class_name)) {
2404+ error = errno;
2405+ goto err;
2406+ }
2407+ } else {
2408+ size_t i;
2409+ for (i = 0; i < apol_vector_get_size(opt->class_vector); ++i) {
2410+ char *class_name;
2411+ class_name = apol_vector_get_element(opt->class_vector, i);
2412+ if (!class_name)
2413+ continue;
2414+ if (apol_avrule_query_append_class(policy, avq, class_name)) {
2415+ error = errno;
2416+ goto err;
2417+ }
2418+ }
2419+ }
2420+ }
2421+
2422+ if (opt->permlist) {
2423+ tmp = strdup(opt->permlist);
2424+ for (tok = strtok(tmp, ","); tok; tok = strtok(NULL, ",")) {
2425+ if (apol_avrule_query_append_perm(policy, avq, tok)) {
2426+ error = errno;
2427+ goto err;
2428+ }
2429+ if ((s = strdup(tok)) == NULL || apol_vector_append(opt->perm_vector, s) < 0) {
2430+ error = errno;
2431+ goto err;
2432+ }
2433+ s = NULL;
2434+ }
2435+ free(tmp);
2436+ }
2437+
2438+ if (!(opt->semantic) && qpol_policy_has_capability(apol_policy_get_qpol(policy), QPOL_CAP_SYN_RULES)) {
2439+ if (apol_syn_avrule_get_by_query(policy, avq, v)) {
2440+ error = errno;
2441+ goto err;
2442+ }
2443+ } else {
2444+ if (apol_avrule_get_by_query(policy, avq, v)) {
2445+ error = errno;
2446+ goto err;
2447+ }
2448+ }
2449+
2450+ apol_avrule_query_destroy(&avq);
2451+ return 0;
2452+
2453+ err:
2454+ apol_vector_destroy(v);
2455+ apol_avrule_query_destroy(&avq);
2456+ free(tmp);
2457+ free(s);
2458+ PyErr_SetString(PyExc_RuntimeError,strerror(error));
2459+ errno = error;
2460+ return -1;
2461+}
2462+
2463+
2464+
2465+static PyObject* get_av_results(const apol_policy_t * policy, const options_t * opt, const apol_vector_t * v)
2466+{
2467+ int retval = -1;
2468+ PyObject *list = PyList_New(0);
2469+ qpol_policy_t *q = apol_policy_get_qpol(policy);
2470+ size_t i, num_rules = 0;
2471+ const qpol_avrule_t *rule = NULL;
2472+ char *tmp = NULL, *rule_str = NULL, *expr = NULL;
2473+ char enable_char = ' ', branch_char = ' ';
2474+ qpol_iterator_t *iter = NULL;
2475+ uint32_t enabled = 0;
2476+
2477+ if (!policy || !v)
2478+ return NULL;
2479+
2480+ if (!(num_rules = apol_vector_get_size(v)))
2481+ return NULL;
2482+
2483+ for (i = 0; i < num_rules; i++) {
2484+ enable_char = branch_char = ' ';
2485+ if (!(rule = apol_vector_get_element(v, i)))
2486+ goto cleanup;
2487+
2488+ if (qpol_avrule_get_is_enabled(q, rule, &enabled))
2489+ goto cleanup;
2490+ if (!enabled)
2491+ continue;
2492+
2493+ const qpol_type_t *type;
2494+ const char *tmp_name;
2495+ uint32_t rule_type = 0;
2496+
2497+ const qpol_class_t *obj_class = NULL;
2498+
2499+ PyObject *dict = PyDict_New();
2500+
2501+ qpol_avrule_get_rule_type(q, rule, &rule_type);
2502+ tmp_name = apol_rule_type_to_str(rule_type);
2503+ PyObject *obj = PyString_FromString(tmp_name);
2504+ PyDict_SetItemString(dict, "type", obj);
2505+ Py_DECREF(obj);
2506+ // source
2507+ qpol_avrule_get_source_type(q, rule, &type);
2508+ qpol_type_get_name(q, type, &tmp_name);
2509+ obj = PyString_FromString(tmp_name);
2510+ PyDict_SetItemString(dict, "scontext", obj);
2511+ Py_DECREF(obj);
2512+
2513+ qpol_avrule_get_target_type(q, rule, &type);
2514+ qpol_type_get_name(q, type, &tmp_name);
2515+ obj = PyString_FromString(tmp_name);
2516+ PyDict_SetItemString(dict, "tcontext", obj);
2517+ Py_DECREF(obj);
2518+
2519+ qpol_avrule_get_object_class(q, rule, &obj_class);
2520+ qpol_type_get_name(q, type, &tmp_name);
2521+ obj = PyString_FromString(tmp_name);
2522+ PyDict_SetItemString(dict, "class", obj);
2523+ Py_DECREF(obj);
2524+ qpol_avrule_get_perm_iter(q, rule, &iter);
2525+ PyObject *permlist = PyList_New(0);
2526+ for (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {
2527+ const char *perm_name = NULL;
2528+ qpol_iterator_get_item(iter, (void **)&perm_name);
2529+ obj = PyString_FromString(perm_name);
2530+ PyList_Append(permlist, obj);
2531+ Py_DECREF(obj);
2532+ }
2533+ PyDict_SetItemString(dict, "permlist", permlist);
2534+ Py_DECREF(permlist);
2535+ PyList_Append(list, dict);
2536+ Py_DECREF(dict);
2537+
2538+ free(rule_str);
2539+ rule_str = NULL;
2540+ free(expr);
2541+ expr = NULL;
2542+ }
2543+ retval = 0;
2544+ cleanup:
2545+ free(tmp);
2546+ free(rule_str);
2547+ free(expr);
2548+ if (retval) {
2549+ Py_DECREF(list);
2550+ return NULL;
2551+ }
2552+ return list;
2553+}
2554+
2555+
2556+PyObject* sesearch(bool allow,
2557+ bool neverallow,
2558+ bool auditallow,
2559+ bool dontaudit,
2560+ const char *src_name,
2561+ const char *tgt_name,
2562+ const char *class_name,
2563+ const char *permlist
2564+ )
2565+{
2566+ options_t cmd_opts;
2567+ int rt = -1;
2568+ PyObject *output = NULL;
2569+
2570+ apol_policy_t *policy = NULL;
2571+ apol_vector_t *v = NULL;
2572+ apol_policy_path_t *pol_path = NULL;
2573+ apol_vector_t *mod_paths = NULL;
2574+ apol_policy_path_type_e path_type = APOL_POLICY_PATH_TYPE_MONOLITHIC;
2575+
2576+ memset(&cmd_opts, 0, sizeof(cmd_opts));
2577+ cmd_opts.indirect = true;
2578+ cmd_opts.allow = allow;
2579+ cmd_opts.nallow = neverallow;
2580+ cmd_opts.auditallow = auditallow;
2581+ cmd_opts.dontaudit = dontaudit;
2582+ if (src_name)
2583+ cmd_opts.src_name = strdup(src_name);
2584+ if (tgt_name)
2585+ cmd_opts.tgt_name = strdup(tgt_name);
2586+ if (class_name)
2587+ cmd_opts.class_name = strdup(class_name);
2588+ if (permlist){
2589+ cmd_opts.perm_vector = apol_vector_create(free);
2590+ cmd_opts.permlist = strdup(permlist);
2591+ }
2592+ int pol_opt = 0;
2593+ if (!(cmd_opts.nallow || cmd_opts.all))
2594+ pol_opt |= QPOL_POLICY_OPTION_NO_NEVERALLOWS;
2595+
2596+
2597+ rt = qpol_default_policy_find(&policy_file);
2598+ if (rt) {
2599+ PyErr_SetString(PyExc_RuntimeError,"No default policy found.");
2600+ return NULL;
2601+ }
2602+ pol_opt |= QPOL_POLICY_OPTION_MATCH_SYSTEM;
2603+
2604+ if (apol_file_is_policy_path_list(policy_file) > 0) {
2605+ pol_path = apol_policy_path_create_from_file(policy_file);
2606+ if (!pol_path) {
2607+ free(policy_file);
2608+ PyErr_SetString(PyExc_RuntimeError,"invalid policy list");
2609+ return NULL;
2610+ }
2611+ }
2612+
2613+ if (!pol_path)
2614+ pol_path = apol_policy_path_create(path_type, policy_file, mod_paths);
2615+ if (!pol_path) {
2616+ free(policy_file);
2617+ PyErr_SetString(PyExc_RuntimeError,strerror(ENOMEM));
2618+ return NULL;
2619+ }
2620+ free(policy_file);
2621+ apol_vector_destroy(&mod_paths);
2622+
2623+ policy = apol_policy_create_from_policy_path(pol_path, pol_opt, NULL, NULL);
2624+ if (!policy) {
2625+ apol_policy_path_destroy(&pol_path);
2626+ PyErr_SetString(PyExc_RuntimeError,strerror(errno));
2627+ return NULL;
2628+ }
2629+ /* handle regex for class name */
2630+ if (cmd_opts.useregex && cmd_opts.class_name != NULL) {
2631+ cmd_opts.class_vector = apol_vector_create(NULL);
2632+ apol_vector_t *qpol_matching_classes = NULL;
2633+ apol_class_query_t *regex_match_query = apol_class_query_create();
2634+ apol_class_query_set_regex(policy, regex_match_query, 1);
2635+ apol_class_query_set_class(policy, regex_match_query, cmd_opts.class_name);
2636+ if (apol_class_get_by_query(policy, regex_match_query, &qpol_matching_classes)) {
2637+ apol_class_query_destroy(&regex_match_query);
2638+ PyErr_SetString(PyExc_RuntimeError,"Query failed");
2639+ goto cleanup;
2640+ }
2641+ const qpol_class_t *class = NULL;
2642+ size_t i;
2643+ for (i = 0; i < apol_vector_get_size(qpol_matching_classes); ++i) {
2644+ const char *class_name;
2645+ class = apol_vector_get_element(qpol_matching_classes, i);
2646+ if (!class)
2647+ break;
2648+ qpol_class_get_name(apol_policy_get_qpol(policy), class, &class_name);
2649+ apol_vector_append(cmd_opts.class_vector, (void *)class_name);
2650+ }
2651+ if (!apol_vector_get_size(qpol_matching_classes)) {
2652+ apol_vector_destroy(&qpol_matching_classes);
2653+ apol_class_query_destroy(&regex_match_query);
2654+ PyErr_SetString(PyExc_RuntimeError,"No classes match expression");
2655+ goto cleanup;
2656+ }
2657+ apol_vector_destroy(&qpol_matching_classes);
2658+ apol_class_query_destroy(&regex_match_query);
2659+ }
2660+
2661+ if (!cmd_opts.semantic && qpol_policy_has_capability(apol_policy_get_qpol(policy), QPOL_CAP_SYN_RULES)) {
2662+ if (qpol_policy_build_syn_rule_table(apol_policy_get_qpol(policy))) {
2663+ apol_policy_destroy(&policy);
2664+ PyErr_SetString(PyExc_RuntimeError,"Query failed");
2665+ goto cleanup;
2666+ }
2667+ }
2668+
2669+ /* if syntactic rules are not available always do semantic search */
2670+ if (!qpol_policy_has_capability(apol_policy_get_qpol(policy), QPOL_CAP_SYN_RULES)) {
2671+ cmd_opts.semantic = 1;
2672+ }
2673+
2674+ /* supress line numbers if doing semantic search or not available */
2675+ if (cmd_opts.semantic || !qpol_policy_has_capability(apol_policy_get_qpol(policy), QPOL_CAP_LINE_NUMBERS)) {
2676+ cmd_opts.lineno = 0;
2677+ }
2678+ if (perform_av_query(policy, &cmd_opts, &v)) {
2679+ goto cleanup;
2680+ }
2681+ if (v) {
2682+ output = get_av_results(policy, &cmd_opts, v);
2683+ }
2684+ apol_vector_destroy(&v);
2685+ cleanup:
2686+ apol_policy_destroy(&policy);
2687+ apol_policy_path_destroy(&pol_path);
2688+ free(cmd_opts.src_name);
2689+ free(cmd_opts.tgt_name);
2690+ free(cmd_opts.class_name);
2691+ free(cmd_opts.permlist);
2692+ free(cmd_opts.bool_name);
2693+ free(cmd_opts.src_role_name);
2694+ free(cmd_opts.tgt_role_name);
2695+ apol_vector_destroy(&cmd_opts.perm_vector);
2696+ apol_vector_destroy(&cmd_opts.class_vector);
2697+
2698+ if (output) return output;
2699+ return Py_None;
2700+}
2701+static int Dict_ContainsInt(PyObject *dict, const char *key){
2702+ PyObject *item = PyDict_GetItemString(dict, key);
2703+ if (item)
2704+ return PyInt_AsLong(item);
2705+ return false;
2706+}
2707+
2708+static const char *Dict_ContainsString(PyObject *dict, const char *key){
2709+ PyObject *item = PyDict_GetItemString(dict, key);
2710+ if (item)
2711+ return PyString_AsString(item);
2712+ return NULL;
2713+}
2714+
2715+PyObject *wrap_sesearch(PyObject *self, PyObject *args){
2716+ PyObject *dict;
2717+ if (!PyArg_ParseTuple(args, "O", &dict))
2718+ return NULL;
2719+ int allow = Dict_ContainsInt(dict, "allow");
2720+ int neverallow = Dict_ContainsInt(dict, "neverallow");
2721+ int auditallow = Dict_ContainsInt(dict, "auditallow");
2722+ int dontaudit = Dict_ContainsInt(dict, "dontaudit");
2723+
2724+ const char *src_name = Dict_ContainsString(dict, "scontext");
2725+ const char *tgt_name = Dict_ContainsString(dict, "tcontext");
2726+ const char *class_name = Dict_ContainsString(dict, "class");
2727+ const char *permlist = Dict_ContainsString(dict, "permlist");
2728+
2729+ return Py_BuildValue("O",sesearch(allow, neverallow, auditallow, dontaudit, src_name, tgt_name, class_name, permlist));
2730+
2731+}
2732+
2733+static PyMethodDef methods[] = {
2734+ {"sesearch", (PyCFunction) wrap_sesearch, METH_VARARGS},
2735+ {NULL, NULL, 0, NULL}
2736+};
2737+
2738+void init_sesearch(){
2739+ PyObject *m;
2740+ m = Py_InitModule("_sesearch", methods);
2741+}
2742diff --git a/python/setools/setup.py b/python/setools/setup.py
2743new file mode 100644
2744index 0000000..053b885
2745--- /dev/null
2746+++ b/python/setools/setup.py
2747@@ -0,0 +1,25 @@
2748+#!/usr/bin/env python
2749+
2750+# Author: Thomas Liu <tliu@redhat.com>
2751+import os
2752+from distutils.core import setup, Extension
2753+LIBS=["apol", "qpol"]
2754+
2755+try:
2756+ inc=os.getenv("INCLUDES").split(" ")
2757+ INCLUDES=map(lambda x: x[2:], inc)
2758+ LIBDIRS=map(lambda x: "/".join(x.split("/")[:-1]), os.getenv("LIBS").split())
2759+except:
2760+ INCLUDES=""
2761+ LIBDIRS=""
2762+
2763+extension_sesearch = Extension("setools._sesearch", [ "sesearch.c"])
2764+extension_sesearch.include_dirs=INCLUDES
2765+extension_sesearch.libraries=LIBS
2766+extension_sesearch.library_dirs=LIBDIRS
2767+extension_seinfo = Extension("setools._seinfo", [ "seinfo.c"])
2768+extension_seinfo.include_dirs=INCLUDES
2769+extension_seinfo.libraries=LIBS
2770+extension_seinfo.library_dirs=LIBDIRS
2771+
2772+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"])
2773--
27741.7.5.4
2775
diff --git a/recipes-security/setools/setools/setools-Changes-to-support-named-file_trans-rules.patch b/recipes-security/setools/setools/setools-Changes-to-support-named-file_trans-rules.patch
new file mode 100644
index 0000000..d44ae21
--- /dev/null
+++ b/recipes-security/setools/setools/setools-Changes-to-support-named-file_trans-rules.patch
@@ -0,0 +1,1511 @@
1From e0f74aa934140ccc6f5a51aa2df6fd19f0c0ee08 Mon Sep 17 00:00:00 2001
2From: Xin Ouyang <Xin.Ouyang@windriver.com>
3Date: Wed, 7 Mar 2012 11:00:19 +0800
4Subject: [PATCH 5/7] setools: Changes to support named file_trans rules
5
6Integrated from Fedora:
7https://community.dev.fedoraproject.org/packages/setools/sources/patches/
8---
9 libapol/include/apol/Makefile.am | 1 +
10 libapol/include/apol/ftrule-query.h | 198 +++++++++++++++++++
11 libapol/include/apol/policy-query.h | 1 +
12 libapol/src/Makefile.am | 1 +
13 libapol/src/ftrule-query.c | 363 +++++++++++++++++++++++++++++++++++
14 libapol/src/libapol.map | 1 +
15 libqpol/include/qpol/Makefile.am | 1 +
16 libqpol/include/qpol/ftrule_query.h | 116 +++++++++++
17 libqpol/include/qpol/policy.h | 1 +
18 libqpol/src/Makefile.am | 1 +
19 libqpol/src/ftrule_query.c | 277 ++++++++++++++++++++++++++
20 libqpol/src/libqpol.map | 1 +
21 libqpol/src/module_compiler.c | 12 ++
22 libqpol/src/policy_define.c | 186 ++++++++++++++++++-
23 libqpol/src/policy_parse.y | 13 +-
24 libqpol/src/policy_scan.l | 1 +
25 secmds/sesearch.c | 101 ++++++++++
26 17 files changed, 1272 insertions(+), 3 deletions(-)
27 create mode 100644 libapol/include/apol/ftrule-query.h
28 create mode 100644 libapol/src/ftrule-query.c
29 create mode 100644 libqpol/include/qpol/ftrule_query.h
30 create mode 100644 libqpol/src/ftrule_query.c
31
32diff --git a/libapol/include/apol/Makefile.am b/libapol/include/apol/Makefile.am
33index 0883c10..e398ff2 100644
34--- a/libapol/include/apol/Makefile.am
35+++ b/libapol/include/apol/Makefile.am
36@@ -27,6 +27,7 @@ apol_HEADERS = \
37 relabel-analysis.h \
38 render.h \
39 role-query.h \
40+ ftrule-query.h \
41 terule-query.h \
42 type-query.h \
43 types-relation-analysis.h \
44diff --git a/libapol/include/apol/ftrule-query.h b/libapol/include/apol/ftrule-query.h
45new file mode 100644
46index 0000000..119c52f
47--- /dev/null
48+++ b/libapol/include/apol/ftrule-query.h
49@@ -0,0 +1,198 @@
50+/**
51+ * @file
52+ *
53+ * Routines to query filename_transition rules of a
54+ * policy.
55+ *
56+ * @author Jeremy A. Mowery jmowery@tresys.com
57+ * @author Jason Tang jtang@tresys.com
58+ *
59+ * Copyright (C) 2006-2007 Tresys Technology, LLC
60+ *
61+ * This library is free software; you can redistribute it and/or
62+ * modify it under the terms of the GNU Lesser General Public
63+ * License as published by the Free Software Foundation; either
64+ * version 2.1 of the License, or (at your option) any later version.
65+ *
66+ * This library is distributed in the hope that it will be useful,
67+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
68+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
69+ * Lesser General Public License for more details.
70+ *
71+ * You should have received a copy of the GNU Lesser General Public
72+ * License along with this library; if not, write to the Free Software
73+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
74+ */
75+
76+#ifndef APOL_FILENAMERULE_QUERY_H
77+#define APOL_FILENAMERULE_QUERY_H
78+
79+#ifdef __cplusplus
80+extern "C"
81+{
82+#endif
83+
84+#include "policy.h"
85+#include "vector.h"
86+#include <qpol/policy.h>
87+
88+ typedef struct apol_filename_trans_query apol_filename_trans_query_t;
89+
90+
91+/******************** filename_transition queries ********************/
92+
93+/**
94+ * Execute a query against all filename_transition rules within the
95+ * policy.
96+ *
97+ * @param p Policy within which to look up filename_transition rules.
98+ * @param r Structure containing parameters for query. If this is
99+ * NULL then return all filename_transition rules.
100+ * @param v Reference to a vector of qpol_filename_trans_t. The vector
101+ * will be allocated by this function. The caller must call
102+ * apol_vector_destroy() afterwards. This will be set to NULL upon no
103+ * results or upon error.
104+ *
105+ * @return 0 on success (including none found), negative on error.
106+ */
107+ extern int apol_filename_trans_get_by_query(const apol_policy_t * p, const apol_filename_trans_query_t * r, apol_vector_t ** v);
108+
109+/**
110+ * Allocate and return a new filename trans query structure. All fields
111+ * are initialized, such that running this blank query results in
112+ * returning all filename_transitions within the policy. The caller must
113+ * call apol_filename_trans_query_destroy() upon the return value
114+ * afterwards.
115+ *
116+ * @return An initialized filename trans query structure, or NULL upon
117+ * error.
118+ */
119+ extern apol_filename_trans_query_t *apol_filename_trans_query_create(void);
120+
121+/**
122+ * Deallocate all memory associated with the referenced filename trans
123+ * query, and then set it to NULL. This function does nothing if the
124+ * query is already NULL.
125+ *
126+ * @param r Reference to a filename trans query structure to destroy.
127+ */
128+ extern void apol_filename_trans_query_destroy(apol_filename_trans_query_t ** r);
129+
130+/**
131+ * Set a filename_trans query to return rules whose source symbol matches
132+ * symbol. Symbol may be a type or attribute; if it is an alias then
133+ * the query will convert it to its primary prior to searching. If
134+ * is_indirect is non-zero then the search will be done indirectly.
135+ * If the symbol is a type, then the query matches rules with one of
136+ * the type's attributes. If the symbol is an attribute, then it
137+ * matches rule with any of the attribute's types.
138+ *
139+ * @param p Policy handler, to report errors.
140+ * @param t TE rule query to set.
141+ * @param symbol Limit query to rules with this symbol as their
142+ * source, or NULL to unset this field.
143+ * @param is_indirect If non-zero, perform indirect matching.
144+ *
145+ * @return 0 on success, negative on error.
146+ */
147+ extern int apol_filename_trans_query_set_source(const apol_policy_t * p, apol_filename_trans_query_t * t, const char *symbol,
148+ int is_indirect);
149+
150+/**
151+ * Set a filename trans query to return rules with a particular target
152+ * symbol. Symbol may be a type or attribute; if it is an alias then
153+ * the query will convert it to its primary prior to searching. If
154+ * is_indirect is non-zero then the search will be done indirectly.
155+ * If the symbol is a type, then the query matches rules with one of
156+ * the type's attributes. If the symbol is an attribute, then it
157+ * matches rule with any of the attribute's types.
158+ *
159+ * @param p Policy handler, to report errors.
160+ * @param r Role trans query to set.
161+ * @param symbol Limit query to rules with this type or attribute as
162+ * their target, or NULL to unset this field.
163+ * @param is_indirect If non-zero, perform indirect matching.
164+ *
165+ * @return 0 on success, negative on error.
166+ */
167+ extern int apol_filename_trans_query_set_target(const apol_policy_t * p, apol_filename_trans_query_t * r, const char *symbol,
168+ int is_indirect);
169+
170+/**
171+ * Set a filename trans query to return rules with a particular default
172+ * filename. This field is ignored if
173+ * apol_filename_trans_query_set_source_any() is set to non-zero.
174+ *
175+ * @param p Policy handler, to report errors.
176+ * @param r Role trans query to set.
177+ * @param filename Limit query to rules with this filename as their default, or
178+ * NULL to unset this field.
179+ *
180+ * @return 0 on success, negative on error.
181+ */
182+ extern int apol_filename_trans_query_set_default(const apol_policy_t * p, apol_filename_trans_query_t * r, const char *filename);
183+
184+/**
185+ * Set at filename_trans query to return rules with this object (non-common)
186+ * class. If more than one class are appended to the query, the
187+ * rule's class must be one of those appended. (I.e., the rule's
188+ * class must be a member of the query's classes.) Pass a NULL to
189+ * clear all classes. Note that this performs straight string
190+ * comparison, ignoring the regex flag.
191+
192+ *
193+ * @param p Policy handler, to report errors.
194+ * @param t TE rule query to set.
195+ * @param obj_class Name of object class to add to search set.
196+ *
197+ * @return 0 on success, negative on error.
198+ */
199+ extern int apol_filename_trans_query_append_class(const apol_policy_t * p, apol_filename_trans_query_t * t, const char *obj_class);
200+
201+/**
202+ * Set a filename trans query to treat the source filename as any. That is,
203+ * use the same symbol for either source or default of a
204+ * filename_transition rule. This flag does nothing if the source filename is
205+ * not set. Note that a filename_transition's target is a type, so thus
206+ * this flag does not affect its searching.
207+ *
208+ * @param p Policy handler, to report errors.
209+ * @param r Role trans query to set.
210+ * @param is_any Non-zero to use source symbol for source or default
211+ * field, 0 to keep source as only source.
212+ *
213+ * @return Always 0.
214+ */
215+ extern int apol_filename_trans_query_set_source_any(const apol_policy_t * p, apol_filename_trans_query_t * r, int is_any);
216+
217+/**
218+ * Set a filename trans query to use regular expression searching for
219+ * source, target, and default fields. Strings will be treated as
220+ * regexes instead of literals. For the target type, matching will
221+ * occur against the type name or any of its aliases.
222+ *
223+ * @param p Policy handler, to report errors.
224+ * @param r Role trans query to set.
225+ * @param is_regex Non-zero to enable regex searching, 0 to disable.
226+ *
227+ * @return Always 0.
228+ */
229+ extern int apol_filename_trans_query_set_regex(const apol_policy_t * p, apol_filename_trans_query_t * r, int is_regex);
230+
231+/**
232+ * Render a filename_transition rule to a string.
233+ *
234+ * @param policy Policy handler, to report errors.
235+ * @param rule The rule to render.
236+ *
237+ * @return A newly malloc()'d string representation of the rule, or NULL on
238+ * failure; if the call fails, errno will be set. The caller is responsible
239+ * for calling free() on the returned string.
240+ */
241+ extern char *apol_filename_trans_render(const apol_policy_t * policy, const qpol_filename_trans_t * rule);
242+
243+#ifdef __cplusplus
244+}
245+#endif
246+
247+#endif
248diff --git a/libapol/include/apol/policy-query.h b/libapol/include/apol/policy-query.h
249index 315f70e..665e4cb 100644
250--- a/libapol/include/apol/policy-query.h
251+++ b/libapol/include/apol/policy-query.h
252@@ -71,6 +71,7 @@ extern "C"
253 #include "terule-query.h"
254 #include "condrule-query.h"
255 #include "rbacrule-query.h"
256+#include "ftrule-query.h"
257 #include "range_trans-query.h"
258 #include "constraint-query.h"
259
260diff --git a/libapol/src/Makefile.am b/libapol/src/Makefile.am
261index 3fa4f06..baaa4f6 100644
262--- a/libapol/src/Makefile.am
263+++ b/libapol/src/Makefile.am
264@@ -40,6 +40,7 @@ libapol_a_SOURCES = \
265 render.c \
266 role-query.c \
267 terule-query.c \
268+ ftrule-query.c \
269 type-query.c \
270 types-relation-analysis.c \
271 user-query.c \
272diff --git a/libapol/src/ftrule-query.c b/libapol/src/ftrule-query.c
273new file mode 100644
274index 0000000..dc248de
275--- /dev/null
276+++ b/libapol/src/ftrule-query.c
277@@ -0,0 +1,363 @@
278+/**
279+ * @file
280+ *
281+ * Provides a way for setools to make queries about type enforcement
282+ * filename_transs within a policy. The caller obtains a query object, fills in
283+ * its parameters, and then runs the query; it obtains a vector of
284+ * results. Searches are conjunctive -- all fields of the search
285+ * query must match for a datum to be added to the results query.
286+ *
287+ * @author Jeremy A. Mowery jmowery@tresys.com
288+ * @author Jason Tang jtang@tresys.com
289+ *
290+ * Copyright (C) 2006-2007 Tresys Technology, LLC
291+ *
292+ * This library is free software; you can redistribute it and/or
293+ * modify it under the terms of the GNU Lesser General Public
294+ * License as published by the Free Software Foundation; either
295+ * version 2.1 of the License, or (at your option) any later version.
296+ *
297+ * This library is distributed in the hope that it will be useful,
298+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
299+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
300+ * Lesser General Public License for more details.
301+ *
302+ * You should have received a copy of the GNU Lesser General Public
303+ * License along with this library; if not, write to the Free Software
304+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
305+ */
306+
307+#include "policy-query-internal.h"
308+
309+#include <errno.h>
310+#include <string.h>
311+
312+struct apol_filename_trans_query
313+{
314+ char *source, *target, *default_type, *name;
315+ apol_vector_t *classes;
316+ unsigned int flags;
317+};
318+
319+
320+/******************** filename_transition queries ********************/
321+
322+int apol_filename_trans_get_by_query(const apol_policy_t * p, const apol_filename_trans_query_t * t, apol_vector_t ** v)
323+{
324+ apol_vector_t *source_list = NULL, *target_list = NULL, *class_list = NULL, *default_list = NULL;
325+ int retval = -1, source_as_any = 0, is_regex = 0, append_filename_trans;
326+ char *bool_name = NULL;
327+ *v = NULL;
328+ unsigned int flags = 0;
329+ qpol_iterator_t *iter = NULL, *type_iter = NULL;
330+
331+ if (t != NULL) {
332+ flags = t->flags;
333+ is_regex = t->flags & APOL_QUERY_REGEX;
334+ if (t->source != NULL &&
335+ (source_list =
336+ apol_query_create_candidate_type_list(p, t->source, is_regex,
337+ t->flags & APOL_QUERY_SOURCE_INDIRECT,
338+ ((t->flags & (APOL_QUERY_SOURCE_TYPE | APOL_QUERY_SOURCE_ATTRIBUTE)) /
339+ APOL_QUERY_SOURCE_TYPE))) == NULL) {
340+ goto cleanup;
341+ }
342+
343+ if ((t->flags & APOL_QUERY_SOURCE_AS_ANY) && t->source != NULL) {
344+ default_list = target_list = source_list;
345+ source_as_any = 1;
346+ } else {
347+ if (t->target != NULL &&
348+ (target_list =
349+ apol_query_create_candidate_type_list(p, t->target, is_regex,
350+ t->flags & APOL_QUERY_TARGET_INDIRECT,
351+ ((t->
352+ flags & (APOL_QUERY_TARGET_TYPE | APOL_QUERY_TARGET_ATTRIBUTE))
353+ / APOL_QUERY_TARGET_TYPE))) == NULL) {
354+ goto cleanup;
355+ }
356+ if (t->default_type != NULL &&
357+ (default_list =
358+ apol_query_create_candidate_type_list(p, t->default_type, is_regex, 0,
359+ APOL_QUERY_SYMBOL_IS_TYPE)) == NULL) {
360+ goto cleanup;
361+ }
362+ }
363+ if (t->classes != NULL &&
364+ apol_vector_get_size(t->classes) > 0 &&
365+ (class_list = apol_query_create_candidate_class_list(p, t->classes)) == NULL) {
366+ goto cleanup;
367+ }
368+ }
369+
370+ if (qpol_policy_get_filename_trans_iter(p->p, &iter) < 0) {
371+ return -1;
372+ }
373+
374+ if ((*v = apol_vector_create(NULL)) == NULL) {
375+ ERR(p, "%s", strerror(errno));
376+ goto cleanup;
377+ }
378+
379+ for (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {
380+ qpol_filename_trans_t *filename_trans;
381+ if (qpol_iterator_get_item(iter, (void **)&filename_trans) < 0) {
382+ goto cleanup;
383+ }
384+ int match_source = 0, match_target = 0, match_default = 0, match_bool = 0;
385+ size_t i;
386+
387+ if (source_list == NULL) {
388+ match_source = 1;
389+ } else {
390+ const qpol_type_t *source_type;
391+ if (qpol_filename_trans_get_source_type(p->p, filename_trans, &source_type) < 0) {
392+ goto cleanup;
393+ }
394+ if (apol_vector_get_index(source_list, source_type, NULL, NULL, &i) == 0) {
395+ match_source = 1;
396+ }
397+ }
398+
399+ /* if source did not match, but treating source symbol
400+ * as any field, then delay rejecting this filename_trans until
401+ * the target and default have been checked */
402+ if (!source_as_any && !match_source) {
403+ continue;
404+ }
405+
406+ if (target_list == NULL || (source_as_any && match_source)) {
407+ match_target = 1;
408+ } else {
409+ const qpol_type_t *target_type;
410+ if (qpol_filename_trans_get_target_type(p->p, filename_trans, &target_type) < 0) {
411+ goto cleanup;
412+ }
413+ if (apol_vector_get_index(target_list, target_type, NULL, NULL, &i) == 0) {
414+ match_target = 1;
415+ }
416+ }
417+
418+ if (!source_as_any && !match_target) {
419+ continue;
420+ }
421+
422+ if (default_list == NULL || (source_as_any && match_source) || (source_as_any && match_target)) {
423+ match_default = 1;
424+ } else {
425+ const qpol_type_t *default_type;
426+ if (qpol_filename_trans_get_default_type(p->p, filename_trans, &default_type) < 0) {
427+ goto cleanup;
428+ }
429+ if (apol_vector_get_index(default_list, default_type, NULL, NULL, &i) == 0) {
430+ match_default = 1;
431+ }
432+ }
433+
434+ if (!source_as_any && !match_default) {
435+ continue;
436+ }
437+ /* at least one thing must match if source_as_any was given */
438+ if (source_as_any && (!match_source && !match_target && !match_default)) {
439+ continue;
440+ }
441+
442+ if (class_list != NULL) {
443+ const qpol_class_t *obj_class;
444+ if (qpol_filename_trans_get_object_class(p->p, filename_trans, &obj_class) < 0) {
445+ goto cleanup;
446+ }
447+ if (apol_vector_get_index(class_list, obj_class, NULL, NULL, &i) < 0) {
448+ continue;
449+ }
450+ }
451+
452+ if (apol_vector_append(*v, filename_trans)) {
453+ ERR(p, "%s", strerror(ENOMEM));
454+ goto cleanup;
455+ }
456+ }
457+
458+ retval = 0;
459+ cleanup:
460+ if (retval != 0) {
461+ apol_vector_destroy(v);
462+ }
463+ apol_vector_destroy(&source_list);
464+ if (!source_as_any) {
465+ apol_vector_destroy(&target_list);
466+ apol_vector_destroy(&default_list);
467+ }
468+ apol_vector_destroy(&class_list);
469+ return retval;
470+}
471+
472+apol_filename_trans_query_t *apol_filename_trans_query_create(void)
473+{
474+ apol_filename_trans_query_t *t = calloc(1, sizeof(apol_filename_trans_query_t));
475+ if (t != NULL) {
476+ t->flags =
477+ (APOL_QUERY_SOURCE_TYPE | APOL_QUERY_SOURCE_ATTRIBUTE | APOL_QUERY_TARGET_TYPE |
478+ APOL_QUERY_TARGET_ATTRIBUTE);
479+ }
480+ return t;
481+}
482+
483+void apol_filename_trans_query_destroy(apol_filename_trans_query_t ** r)
484+{
485+ if (r != NULL && *r != NULL) {
486+ free((*r)->source);
487+ free((*r)->target);
488+ free((*r)->default_type);
489+ free((*r)->name);
490+ free(*r);
491+ *r = NULL;
492+ }
493+}
494+
495+int apol_filename_trans_query_set_source(const apol_policy_t * p, apol_filename_trans_query_t * t, const char *filename, int is_indirect)
496+{
497+ apol_query_set_flag(p, &t->flags, is_indirect, APOL_QUERY_TARGET_INDIRECT);
498+ return apol_query_set(p, &t->source, NULL, filename);
499+}
500+
501+int apol_filename_trans_query_set_target(const apol_policy_t * p, apol_filename_trans_query_t * t, const char *type, int is_indirect)
502+{
503+ apol_query_set_flag(p, &t->flags, is_indirect, APOL_QUERY_TARGET_INDIRECT);
504+ return apol_query_set(p, &t->target, NULL, type);
505+}
506+
507+int apol_filename_trans_query_set_default(const apol_policy_t * p, apol_filename_trans_query_t * t, const char *symbol)
508+{
509+ return apol_query_set(p, &t->default_type, NULL, symbol);
510+}
511+
512+int apol_filename_trans_query_append_class(const apol_policy_t * p, apol_filename_trans_query_t * t, const char *obj_class)
513+{
514+ char *s = NULL;
515+ if (obj_class == NULL) {
516+ apol_vector_destroy(&t->classes);
517+ } else if ((s = strdup(obj_class)) == NULL || (t->classes == NULL && (t->classes = apol_vector_create(free)) == NULL)
518+ || apol_vector_append(t->classes, s) < 0) {
519+ ERR(p, "%s", strerror(errno));
520+ free(s);
521+ return -1;
522+ }
523+ return 0;
524+}
525+
526+int apol_filename_trans_query_set_name(const apol_policy_t * p, apol_filename_trans_query_t * t, const char *filename)
527+{
528+ return apol_query_set(p, &t->name, NULL, filename);
529+}
530+
531+int apol_filename_trans_query_set_source_any(const apol_policy_t * p, apol_filename_trans_query_t * t, int is_any)
532+{
533+ return apol_query_set_flag(p, &t->flags, is_any, APOL_QUERY_SOURCE_AS_ANY);
534+}
535+
536+int apol_filename_trans_query_set_regex(const apol_policy_t * p, apol_filename_trans_query_t * t, int is_regex)
537+{
538+ return apol_query_set_regex(p, &t->flags, is_regex);
539+}
540+
541+char *apol_filename_trans_render(const apol_policy_t * policy, const qpol_filename_trans_t * filename_trans)
542+{
543+ char *tmp = NULL;
544+ const char *tmp_name = NULL;
545+ const char *filename_trans_type_str;
546+ int error = 0;
547+ size_t tmp_sz = 0;
548+ uint32_t filename_trans_type = 0;
549+ const qpol_type_t *type = NULL;
550+ const qpol_class_t *obj_class = NULL;
551+
552+ if (!policy || !filename_trans) {
553+ ERR(policy, "%s", strerror(EINVAL));
554+ errno = EINVAL;
555+ return NULL;
556+ }
557+
558+ /* source type */
559+ if (qpol_filename_trans_get_source_type(policy->p, filename_trans, &type)) {
560+ error = errno;
561+ goto err;
562+ }
563+ if (qpol_type_get_name(policy->p, type, &tmp_name)) {
564+ error = errno;
565+ goto err;
566+ }
567+ if (apol_str_appendf(&tmp, &tmp_sz, "transition_type %s ", tmp_name)) {
568+ error = errno;
569+ ERR(policy, "%s", strerror(error));
570+ goto err;
571+ }
572+
573+ /* target type */
574+ if (qpol_filename_trans_get_target_type(policy->p, filename_trans, &type)) {
575+ error = errno;
576+ goto err;
577+ }
578+ if (qpol_type_get_name(policy->p, type, &tmp_name)) {
579+ error = errno;
580+ goto err;
581+ }
582+ if (apol_str_appendf(&tmp, &tmp_sz, "%s : ", tmp_name)) {
583+ error = errno;
584+ ERR(policy, "%s", strerror(error));
585+ goto err;
586+ }
587+
588+ /* object class */
589+ if (qpol_filename_trans_get_object_class(policy->p, filename_trans, &obj_class)) {
590+ error = errno;
591+ goto err;
592+ }
593+ if (qpol_class_get_name(policy->p, obj_class, &tmp_name)) {
594+ error = errno;
595+ goto err;
596+ }
597+ if (apol_str_appendf(&tmp, &tmp_sz, "%s ", tmp_name)) {
598+ error = errno;
599+ ERR(policy, "%s", strerror(error));
600+ goto err;
601+ }
602+
603+ /* default type */
604+ if (qpol_filename_trans_get_default_type(policy->p, filename_trans, &type)) {
605+ error = errno;
606+ goto err;
607+ }
608+ if (qpol_type_get_name(policy->p, type, &tmp_name)) {
609+ error = errno;
610+ goto err;
611+ }
612+ if (apol_str_appendf(&tmp, &tmp_sz, "%s", tmp_name)) {
613+ error = errno;
614+ ERR(policy, "%s", strerror(error));
615+ goto err;
616+ }
617+
618+ if (qpol_filename_trans_get_filename(policy->p, filename_trans, &tmp_name)) {
619+ error = errno;
620+ goto err;
621+ }
622+
623+ if (apol_str_appendf(&tmp, &tmp_sz, " %s", tmp_name)) {
624+ error = errno;
625+ ERR(policy, "%s", strerror(error));
626+ goto err;
627+ }
628+
629+ if (apol_str_appendf(&tmp, &tmp_sz, ";")) {
630+ error = errno;
631+ ERR(policy, "%s", strerror(error));
632+ goto err;
633+ }
634+ return tmp;
635+
636+ err:
637+ free(tmp);
638+ errno = error;
639+ return NULL;
640+}
641diff --git a/libapol/src/libapol.map b/libapol/src/libapol.map
642index 4894374..7657a2d 100644
643--- a/libapol/src/libapol.map
644+++ b/libapol/src/libapol.map
645@@ -34,6 +34,7 @@ VERS_4.0{
646 apol_protocol_to_str;
647 apol_qpol_context_render;
648 apol_range_trans_*;
649+ apol_filename_trans_*;
650 apol_relabel_*;
651 apol_role_*;
652 apol_role_allow_*;
653diff --git a/libqpol/include/qpol/Makefile.am b/libqpol/include/qpol/Makefile.am
654index b55acb7..9b570e1 100644
655--- a/libqpol/include/qpol/Makefile.am
656+++ b/libqpol/include/qpol/Makefile.am
657@@ -25,6 +25,7 @@ qpol_HEADERS = \
658 role_query.h \
659 syn_rule_query.h \
660 terule_query.h \
661+ ftrule_query.h \
662 type_query.h \
663 user_query.h \
664 util.h
665diff --git a/libqpol/include/qpol/ftrule_query.h b/libqpol/include/qpol/ftrule_query.h
666new file mode 100644
667index 0000000..1f533a4
668--- /dev/null
669+++ b/libqpol/include/qpol/ftrule_query.h
670@@ -0,0 +1,116 @@
671+/**
672+ * @file
673+ * Defines public interface for iterating over FTRULE rules.
674+ *
675+ * @author Kevin Carr kcarr@tresys.com
676+ * @author Jeremy A. Mowery jmowery@tresys.com
677+ * @author Jason Tang jtang@tresys.com
678+ *
679+ * Copyright (C) 2006-2007 Tresys Technology, LLC
680+ *
681+ * This library is free software; you can redistribute it and/or
682+ * modify it under the terms of the GNU Lesser General Public
683+ * License as published by the Free Software Foundation; either
684+ * version 2.1 of the License, or (at your option) any later version.
685+ *
686+ * This library is distributed in the hope that it will be useful,
687+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
688+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
689+ * Lesser General Public License for more details.
690+ *
691+ * You should have received a copy of the GNU Lesser General Public
692+ * License along with this library; if not, write to the Free Software
693+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
694+ */
695+
696+#ifndef QPOL_FTRULERULE_QUERY
697+#define QPOL_FTRULERULE_QUERY
698+
699+#ifdef __cplusplus
700+extern "C"
701+{
702+#endif
703+
704+#include <qpol/policy.h>
705+#include <qpol/iterator.h>
706+
707+ typedef struct qpol_filename_trans qpol_filename_trans_t;
708+
709+/**
710+ * Get an iterator over all filename transition rules in the policy.
711+ * @param policy Policy from which to create the iterator.
712+ * @param iter Iterator over items of type qpol_filename_trans_t returned.
713+ * The caller is responsible for calling qpol_iterator_destroy()
714+ * to free memory used by this iterator.
715+ * It is important to note that this iterator is only valid as long as
716+ * the policy is unmodifed.
717+ * @returm 0 on success and < 0 on failure; if the call fails,
718+ * errno will be set and *iter will be NULL.
719+ */
720+ extern int qpol_policy_get_filename_trans_iter(const qpol_policy_t * policy, qpol_iterator_t ** iter);
721+
722+/**
723+ * Get the source type from a filename transition rule.
724+ * @param policy The policy from which the rule comes.
725+ * @param rule The rule from which to get the source type.
726+ * @param source Pointer in which to store the source type.
727+ * The caller should not free this pointer.
728+ * @return 0 on success and < 0 on failure; if the call fails,
729+ * errno will be set and *source will be NULL.
730+ */
731+ extern int qpol_filename_trans_get_source_type(const qpol_policy_t * policy, const qpol_filename_trans_t * rule,
732+ const qpol_type_t ** source);
733+
734+/**
735+ * Get the target type from a filename transition rule.
736+ * @param policy The policy from which the rule comes.
737+ * @param rule The rule from which to get the target type.
738+ * @param target Pointer in which to store the target type.
739+ * The caller should not free this pointer.
740+ * @return 0 on success and < 0 on failure; if the call fails,
741+ * errno will be set and *target will be NULL.
742+ */
743+ extern int qpol_filename_trans_get_target_type(const qpol_policy_t * policy, const qpol_filename_trans_t * rule,
744+ const qpol_type_t ** target);
745+
746+/**
747+ * Get the default type from a type rule.
748+ * @param policy Policy from which the rule comes.
749+ * @param rule The rule from which to get the default type.
750+ * @param dflt Pointer in which to store the default type.
751+ * The caller should not free this pointer.
752+ * @returm 0 on success and < 0 on failure; if the call fails,
753+ * errno will be set and *dflt will be NULL.
754+ */
755+ extern int qpol_filename_trans_get_default_type(const qpol_policy_t * policy, const qpol_filename_trans_t * rule,
756+ const qpol_type_t ** dflt);
757+
758+/**
759+ * Get the object class from a type rule.
760+ * @param policy Policy from which the rule comes.
761+ * @param rule The rule from which to get the object class.
762+ * @param obj_class Pointer in which to store the object class.
763+ * The caller should not free this pointer.
764+ * @returm 0 on success and < 0 on failure; if the call fails,
765+ * errno will be set and *obj_class will be NULL.
766+ */
767+ extern int qpol_filename_trans_get_object_class(const qpol_policy_t * policy, const qpol_filename_trans_t * rule,
768+ const qpol_class_t ** obj_class);
769+
770+/**
771+ * Get the transition filename type from a type rule.
772+ * @param policy Policy from which the rule comes.
773+ * @param rule The rule from which to get the transition filename.
774+ * @param target Pointer in which to store the transition filename.
775+ * The caller should not free this pointer.
776+ * @returm 0 on success and < 0 on failure; if the call fails,
777+ * errno will be set and *target will be NULL.
778+ */
779+ extern int qpol_filename_trans_get_filename(const qpol_policy_t * policy, const qpol_filename_trans_t * rule,
780+ const char ** name);
781+
782+#ifdef __cplusplus
783+}
784+#endif
785+
786+#endif /* QPOL_FTRULERULE_QUERY */
787diff --git a/libqpol/include/qpol/policy.h b/libqpol/include/qpol/policy.h
788index ae4ea08..bf85718 100644
789--- a/libqpol/include/qpol/policy.h
790+++ b/libqpol/include/qpol/policy.h
791@@ -55,6 +55,7 @@ extern "C"
792 #include <qpol/polcap_query.h>
793 #include <qpol/portcon_query.h>
794 #include <qpol/rbacrule_query.h>
795+#include <qpol/ftrule_query.h>
796 #include <qpol/role_query.h>
797 #include <qpol/syn_rule_query.h>
798 #include <qpol/terule_query.h>
799diff --git a/libqpol/src/Makefile.am b/libqpol/src/Makefile.am
800index 34d87a6..0889a61 100644
801--- a/libqpol/src/Makefile.am
802+++ b/libqpol/src/Makefile.am
803@@ -48,6 +48,7 @@ libqpol_a_SOURCES = \
804 syn_rule_internal.h \
805 syn_rule_query.c \
806 terule_query.c \
807+ ftrule_query.c \
808 type_query.c \
809 user_query.c \
810 util.c \
811diff --git a/libqpol/src/ftrule_query.c b/libqpol/src/ftrule_query.c
812new file mode 100644
813index 0000000..d6db848
814--- /dev/null
815+++ b/libqpol/src/ftrule_query.c
816@@ -0,0 +1,277 @@
817+/**
818+ * @file
819+ * Defines public interface for iterating over RBAC rules.
820+ *
821+ * @author Jeremy A. Mowery jmowery@tresys.com
822+ * @author Jason Tang jtang@tresys.com
823+ *
824+ * Copyright (C) 2006-2007 Tresys Technology, LLC
825+ *
826+ * This library is free software; you can redistribute it and/or
827+ * modify it under the terms of the GNU Lesser General Public
828+ * License as published by the Free Software Foundation; either
829+ * version 2.1 of the License, or (at your option) any later version.
830+ *
831+ * This library is distributed in the hope that it will be useful,
832+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
833+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
834+ * Lesser General Public License for more details.
835+ *
836+ * You should have received a copy of the GNU Lesser General Public
837+ * License along with this library; if not, write to the Free Software
838+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
839+ */
840+
841+#include <qpol/iterator.h>
842+#include <qpol/policy.h>
843+#include <qpol/ftrule_query.h>
844+#include <stdlib.h>
845+#include "iterator_internal.h"
846+#include "qpol_internal.h"
847+#include <sepol/policydb/policydb.h>
848+
849+typedef struct filename_trans_state
850+{
851+ filename_trans_t *head;
852+ filename_trans_t *cur;
853+} filename_trans_state_t;
854+
855+static int filename_trans_state_end(const qpol_iterator_t * iter)
856+{
857+ filename_trans_state_t *fts = NULL;
858+
859+ if (!iter || !(fts = qpol_iterator_state(iter))) {
860+ errno = EINVAL;
861+ return STATUS_ERR;
862+ }
863+
864+ return fts->cur ? 0 : 1;
865+}
866+
867+static void *filename_trans_state_get_cur(const qpol_iterator_t * iter)
868+{
869+ filename_trans_state_t *fts = NULL;
870+ const policydb_t *db = NULL;
871+
872+ if (!iter || !(fts = qpol_iterator_state(iter)) || !(db = qpol_iterator_policy(iter)) || filename_trans_state_end(iter)) {
873+ errno = EINVAL;
874+ return NULL;
875+ }
876+
877+ return fts->cur;
878+}
879+
880+static int filename_trans_state_next(qpol_iterator_t * iter)
881+{
882+ filename_trans_state_t *fts = NULL;
883+ const policydb_t *db = NULL;
884+
885+ if (!iter || !(fts = qpol_iterator_state(iter)) || !(db = qpol_iterator_policy(iter))) {
886+ errno = EINVAL;
887+ return STATUS_ERR;
888+ }
889+
890+ if (filename_trans_state_end(iter)) {
891+ errno = ERANGE;
892+ return STATUS_ERR;
893+ }
894+
895+ fts->cur = fts->cur->next;
896+
897+ return STATUS_SUCCESS;
898+}
899+
900+static size_t filename_trans_state_size(const qpol_iterator_t * iter)
901+{
902+ filename_trans_state_t *fts = NULL;
903+ const policydb_t *db = NULL;
904+ filename_trans_t *tmp = NULL;
905+ size_t count = 0;
906+
907+ if (!iter || !(fts = qpol_iterator_state(iter)) || !(db = qpol_iterator_policy(iter))) {
908+ errno = EINVAL;
909+ return STATUS_ERR;
910+ }
911+
912+ for (tmp = fts->head; tmp; tmp = tmp->next)
913+ count++;
914+
915+ return count;
916+}
917+
918+int qpol_policy_get_filename_trans_iter(const qpol_policy_t * policy, qpol_iterator_t ** iter)
919+{
920+ policydb_t *db = NULL;
921+ filename_trans_state_t *fts = NULL;
922+ int error = 0;
923+
924+ if (iter)
925+ *iter = NULL;
926+
927+ if (!policy || !iter) {
928+ ERR(policy, "%s", strerror(EINVAL));
929+ errno = EINVAL;
930+ return STATUS_ERR;
931+ }
932+
933+ db = &policy->p->p;
934+
935+ fts = calloc(1, sizeof(filename_trans_state_t));
936+ if (!fts) {
937+ /* errno set by calloc */
938+ ERR(policy, "%s", strerror(errno));
939+ return STATUS_ERR;
940+ }
941+ fts->head = fts->cur = db->filename_trans;
942+
943+ if (qpol_iterator_create
944+ (policy, (void *)fts, filename_trans_state_get_cur, filename_trans_state_next, filename_trans_state_end, filename_trans_state_size,
945+ free, iter)) {
946+ error = errno;
947+ free(fts);
948+ errno = error;
949+ return STATUS_ERR;
950+ }
951+
952+ return STATUS_SUCCESS;
953+}
954+
955+int qpol_filename_trans_get_source_type(const qpol_policy_t * policy, const qpol_filename_trans_t * rule, const qpol_type_t ** source)
956+{
957+ policydb_t *db = NULL;
958+ filename_trans_t *ft = NULL;
959+
960+ if (source) {
961+ *source = NULL;
962+ }
963+
964+ if (!policy || !rule || !source) {
965+ ERR(policy, "%s", strerror(EINVAL));
966+ errno = EINVAL;
967+ return STATUS_ERR;
968+ }
969+
970+ db = &policy->p->p;
971+ ft = (filename_trans_t *) rule;
972+
973+ *source = (qpol_type_t *) db->type_val_to_struct[ft->stype - 1];
974+
975+ return STATUS_SUCCESS;
976+}
977+
978+int qpol_filename_trans_get_target_type(const qpol_policy_t * policy, const qpol_filename_trans_t * rule, const qpol_type_t ** target)
979+{
980+ policydb_t *db = NULL;
981+ filename_trans_t *ft = NULL;
982+
983+ if (target) {
984+ *target = NULL;
985+ }
986+
987+ if (!policy || !rule || !target) {
988+ ERR(policy, "%s", strerror(EINVAL));
989+ errno = EINVAL;
990+ return STATUS_ERR;
991+ }
992+
993+ db = &policy->p->p;
994+ ft = (filename_trans_t *) rule;
995+
996+ *target = (qpol_type_t *) db->type_val_to_struct[ft->ttype - 1];
997+
998+ return STATUS_SUCCESS;
999+}
1000+
1001+int qpol_filename_trans_get_object_class(const qpol_policy_t * policy, const qpol_filename_trans_t * rule,
1002+ const qpol_class_t ** obj_class)
1003+{
1004+ policydb_t *db = NULL;
1005+ filename_trans_t *ft = NULL;
1006+
1007+ if (obj_class) {
1008+ *obj_class = NULL;
1009+ }
1010+
1011+ if (!policy || !rule || !obj_class) {
1012+ ERR(policy, "%s", strerror(EINVAL));
1013+ errno = EINVAL;
1014+ return STATUS_ERR;
1015+ }
1016+
1017+ db = &policy->p->p;
1018+ ft = (filename_trans_t *) rule;
1019+
1020+ *obj_class = (qpol_class_t *) db->class_val_to_struct[ft->tclass - 1];
1021+
1022+ return STATUS_SUCCESS;
1023+}
1024+
1025+int qpol_filename_trans_get_trans_type(const qpol_policy_t * policy, const qpol_filename_trans_t * rule, const qpol_type_t ** output_type)
1026+{
1027+ policydb_t *db = NULL;
1028+ filename_trans_t *ft = NULL;
1029+
1030+ if (output_type) {
1031+ *output_type = NULL;
1032+ }
1033+
1034+ if (!policy || !rule || !output_type) {
1035+ ERR(policy, "%s", strerror(EINVAL));
1036+ errno = EINVAL;
1037+ return STATUS_ERR;
1038+ }
1039+
1040+ db = &policy->p->p;
1041+ ft = (filename_trans_t *) rule;
1042+
1043+ *output_type = (qpol_type_t *) db->type_val_to_struct[ft->otype - 1];
1044+
1045+ return STATUS_SUCCESS;
1046+}
1047+
1048+int qpol_filename_trans_get_default_type(const qpol_policy_t * policy, const qpol_filename_trans_t * rule, const qpol_type_t ** dflt)
1049+{
1050+ policydb_t *db = NULL;
1051+ filename_trans_t *ft = NULL;
1052+
1053+ if (dflt) {
1054+ *dflt = NULL;
1055+ }
1056+
1057+ if (!policy || !rule || !dflt) {
1058+ ERR(policy, "%s", strerror(EINVAL));
1059+ errno = EINVAL;
1060+ return STATUS_ERR;
1061+ }
1062+
1063+ db = &policy->p->p;
1064+ ft = (filename_trans_t *) rule;
1065+
1066+ *dflt = (qpol_type_t *) db->type_val_to_struct[ft->otype - 1];
1067+
1068+ return STATUS_SUCCESS;
1069+}
1070+
1071+int qpol_filename_trans_get_filename(const qpol_policy_t * policy, const qpol_filename_trans_t * rule, const char ** name)
1072+{
1073+ policydb_t *db = NULL;
1074+ filename_trans_t *ft = NULL;
1075+
1076+ if (name) {
1077+ *name = NULL;
1078+ }
1079+
1080+ if (!policy || !rule || !name) {
1081+ ERR(policy, "%s", strerror(EINVAL));
1082+ errno = EINVAL;
1083+ return STATUS_ERR;
1084+ }
1085+
1086+ db = &policy->p->p;
1087+ ft = (filename_trans_t *) rule;
1088+
1089+ *name = ft->name;
1090+
1091+ return STATUS_SUCCESS;
1092+}
1093+
1094diff --git a/libqpol/src/libqpol.map b/libqpol/src/libqpol.map
1095index dd293bc..6973cca 100644
1096--- a/libqpol/src/libqpol.map
1097+++ b/libqpol/src/libqpol.map
1098@@ -34,6 +34,7 @@ VERS_1.2 {
1099 qpol_policy_reevaluate_conds;
1100 qpol_portcon_*;
1101 qpol_range_trans_*;
1102+ qpol_filename_trans_*;
1103 qpol_role_*;
1104 qpol_syn_avrule_*;
1105 qpol_syn_terule_*;
1106diff --git a/libqpol/src/module_compiler.c b/libqpol/src/module_compiler.c
1107index dc19798..b06e285 100644
1108--- a/libqpol/src/module_compiler.c
1109+++ b/libqpol/src/module_compiler.c
1110@@ -1247,6 +1247,18 @@ void append_role_allow(role_allow_rule_t * role_allow_rules)
1111 }
1112
1113 /* this doesn't actually append, but really prepends it */
1114+void append_filename_trans(filename_trans_rule_t * filename_trans_rules)
1115+{
1116+ avrule_decl_t *decl = stack_top->decl;
1117+
1118+ /* filename transitions are not allowed within conditionals */
1119+ assert(stack_top->type == 1);
1120+
1121+ filename_trans_rules->next = decl->filename_trans_rules;
1122+ decl->filename_trans_rules = filename_trans_rules;
1123+}
1124+
1125+/* this doesn't actually append, but really prepends it */
1126 void append_range_trans(range_trans_rule_t * range_tr_rules)
1127 {
1128 avrule_decl_t *decl = stack_top->decl;
1129diff --git a/libqpol/src/policy_define.c b/libqpol/src/policy_define.c
1130index c94f7aa..0f3a45a 100644
1131--- a/libqpol/src/policy_define.c
1132+++ b/libqpol/src/policy_define.c
1133@@ -2133,7 +2133,7 @@ int define_role_trans(void)
1134
1135 /* This ebitmap business is just to ensure that there are not conflicting role_trans rules */
1136 #ifdef HAVE_SEPOL_USER_ROLE_MAPPING
1137- if (role_set_expand(&roles, &e_roles, policydbp, NULL))
1138+ if (role_set_expand(&roles, &e_roles, policydbp, NULL, NULL))
1139 #else
1140 if (role_set_expand(&roles, &e_roles, policydbp))
1141 #endif
1142@@ -2226,6 +2226,190 @@ int define_role_allow(void)
1143 return 0;
1144 }
1145
1146+avrule_t *define_cond_filename_trans(void)
1147+{
1148+ yyerror("type transitions with a filename not allowed inside "
1149+ "conditionals\n");
1150+ return COND_ERR;
1151+}
1152+
1153+int define_filename_trans(void)
1154+{
1155+ char *id, *name = NULL;
1156+ type_set_t stypes, ttypes;
1157+ ebitmap_t e_stypes, e_ttypes;
1158+ ebitmap_t e_tclasses;
1159+ ebitmap_node_t *snode, *tnode, *cnode;
1160+ filename_trans_t *ft;
1161+ filename_trans_rule_t *ftr;
1162+ class_datum_t *cladatum;
1163+ type_datum_t *typdatum;
1164+ uint32_t otype;
1165+ unsigned int c, s, t;
1166+ int add;
1167+
1168+ if (pass == 1) {
1169+ /* stype */
1170+ while ((id = queue_remove(id_queue)))
1171+ free(id);
1172+ /* ttype */
1173+ while ((id = queue_remove(id_queue)))
1174+ free(id);
1175+ /* tclass */
1176+ while ((id = queue_remove(id_queue)))
1177+ free(id);
1178+ /* otype */
1179+ id = queue_remove(id_queue);
1180+ free(id);
1181+ /* name */
1182+ id = queue_remove(id_queue);
1183+ free(id);
1184+ return 0;
1185+ }
1186+
1187+
1188+ add = 1;
1189+ type_set_init(&stypes);
1190+ while ((id = queue_remove(id_queue))) {
1191+ if (set_types(&stypes, id, &add, 0))
1192+ goto bad;
1193+ }
1194+
1195+ add =1;
1196+ type_set_init(&ttypes);
1197+ while ((id = queue_remove(id_queue))) {
1198+ if (set_types(&ttypes, id, &add, 0))
1199+ goto bad;
1200+ }
1201+
1202+ ebitmap_init(&e_tclasses);
1203+ while ((id = queue_remove(id_queue))) {
1204+ if (!is_id_in_scope(SYM_CLASSES, id)) {
1205+ yyerror2("class %s is not within scope", id);
1206+ free(id);
1207+ goto bad;
1208+ }
1209+ cladatum = hashtab_search(policydbp->p_classes.table, id);
1210+ if (!cladatum) {
1211+ yyerror2("unknown class %s", id);
1212+ goto bad;
1213+ }
1214+ if (ebitmap_set_bit(&e_tclasses, cladatum->s.value - 1, TRUE)) {
1215+ yyerror("Out of memory");
1216+ goto bad;
1217+ }
1218+ free(id);
1219+ }
1220+
1221+ id = (char *)queue_remove(id_queue);
1222+ if (!id) {
1223+ yyerror("no otype in transition definition?");
1224+ goto bad;
1225+ }
1226+ if (!is_id_in_scope(SYM_TYPES, id)) {
1227+ yyerror2("type %s is not within scope", id);
1228+ free(id);
1229+ goto bad;
1230+ }
1231+ typdatum = hashtab_search(policydbp->p_types.table, id);
1232+ if (!typdatum) {
1233+ yyerror2("unknown type %s used in transition definition", id);
1234+ goto bad;
1235+ }
1236+ free(id);
1237+ otype = typdatum->s.value;
1238+
1239+ name = queue_remove(id_queue);
1240+ if (!name) {
1241+ yyerror("no pathname specified in filename_trans definition?");
1242+ goto bad;
1243+ }
1244+
1245+ /* We expand the class set into seperate rules. We expand the types
1246+ * just to make sure there are not duplicates. They will get turned
1247+ * into seperate rules later */
1248+ ebitmap_init(&e_stypes);
1249+ if (type_set_expand(&stypes, &e_stypes, policydbp, 1))
1250+ goto bad;
1251+
1252+ ebitmap_init(&e_ttypes);
1253+ if (type_set_expand(&ttypes, &e_ttypes, policydbp, 1))
1254+ goto bad;
1255+
1256+ ebitmap_for_each_bit(&e_tclasses, cnode, c) {
1257+ if (!ebitmap_node_get_bit(cnode, c))
1258+ continue;
1259+ ebitmap_for_each_bit(&e_stypes, snode, s) {
1260+ if (!ebitmap_node_get_bit(snode, s))
1261+ continue;
1262+ ebitmap_for_each_bit(&e_ttypes, tnode, t) {
1263+ if (!ebitmap_node_get_bit(tnode, t))
1264+ continue;
1265+
1266+ for (ft = policydbp->filename_trans; ft; ft = ft->next) {
1267+ if (ft->stype == (s + 1) &&
1268+ ft->ttype == (t + 1) &&
1269+ ft->tclass == (c + 1) &&
1270+ !strcmp(ft->name, name)) {
1271+ yyerror2("duplicate filename transition for: filename_trans %s %s %s:%s",
1272+ name,
1273+ policydbp->p_type_val_to_name[s],
1274+ policydbp->p_type_val_to_name[t],
1275+ policydbp->p_class_val_to_name[c]);
1276+ goto bad;
1277+ }
1278+ }
1279+
1280+ ft = malloc(sizeof(*ft));
1281+ if (!ft) {
1282+ yyerror("out of memory");
1283+ goto bad;
1284+ }
1285+ memset(ft, 0, sizeof(*ft));
1286+
1287+ ft->next = policydbp->filename_trans;
1288+ policydbp->filename_trans = ft;
1289+
1290+ ft->name = strdup(name);
1291+ if (!ft->name) {
1292+ yyerror("out of memory");
1293+ goto bad;
1294+ }
1295+ ft->stype = s + 1;
1296+ ft->ttype = t + 1;
1297+ ft->tclass = c + 1;
1298+ ft->otype = otype;
1299+ }
1300+ }
1301+
1302+ /* Now add the real rule since we didn't find any duplicates */
1303+ ftr = malloc(sizeof(*ftr));
1304+ if (!ftr) {
1305+ yyerror("out of memory");
1306+ goto bad;
1307+ }
1308+ filename_trans_rule_init(ftr);
1309+ append_filename_trans(ftr);
1310+
1311+ ftr->name = strdup(name);
1312+ ftr->stypes = stypes;
1313+ ftr->ttypes = ttypes;
1314+ ftr->tclass = c + 1;
1315+ ftr->otype = otype;
1316+ }
1317+
1318+ free(name);
1319+ ebitmap_destroy(&e_stypes);
1320+ ebitmap_destroy(&e_ttypes);
1321+ ebitmap_destroy(&e_tclasses);
1322+
1323+ return 0;
1324+
1325+bad:
1326+ free(name);
1327+ return -1;
1328+}
1329+
1330 static constraint_expr_t *constraint_expr_clone(constraint_expr_t * expr)
1331 {
1332 constraint_expr_t *h = NULL, *l = NULL, *e, *newe;
1333diff --git a/libqpol/src/policy_parse.y b/libqpol/src/policy_parse.y
1334index 84f4114..dc16c6f 100644
1335--- a/libqpol/src/policy_parse.y
1336+++ b/libqpol/src/policy_parse.y
1337@@ -98,6 +98,7 @@ extern char *qpol_src_inputlim;/* end of data */
1338 %type <require_func> require_decl_def
1339
1340 %token PATH
1341+%token FILENAME
1342 %token CLONE
1343 %token COMMON
1344 %token CLASS
1345@@ -360,7 +361,10 @@ cond_rule_def : cond_transition_def
1346 | require_block
1347 { $$ = NULL; }
1348 ;
1349-cond_transition_def : TYPE_TRANSITION names names ':' names identifier ';'
1350+cond_transition_def : TYPE_TRANSITION names names ':' names identifier filename ';'
1351+ { $$ = define_cond_filename_trans() ;
1352+ if ($$ == COND_ERR) return -1;}
1353+ | TYPE_TRANSITION names names ':' names identifier ';'
1354 { $$ = define_cond_compute_type(AVRULE_TRANSITION) ;
1355 if ($$ == COND_ERR) return -1;}
1356 | TYPE_MEMBER names names ':' names identifier ';'
1357@@ -395,7 +399,9 @@ cond_dontaudit_def : DONTAUDIT names names ':' names names ';'
1358 { $$ = define_cond_te_avtab(AVRULE_DONTAUDIT);
1359 if ($$ == COND_ERR) return -1; }
1360 ;
1361-transition_def : TYPE_TRANSITION names names ':' names identifier ';'
1362+transition_def : TYPE_TRANSITION names names ':' names identifier filename ';'
1363+ {if (define_filename_trans()) return -1; }
1364+ | TYPE_TRANSITION names names ':' names identifier ';'
1365 {if (define_compute_type(AVRULE_TRANSITION)) return -1;}
1366 | TYPE_MEMBER names names ':' names identifier ';'
1367 {if (define_compute_type(AVRULE_MEMBER)) return -1;}
1368@@ -752,6 +758,9 @@ identifier : IDENTIFIER
1369 path : PATH
1370 { if (insert_id(yytext,0)) return -1; }
1371 ;
1372+filename : FILENAME
1373+ { yytext[strlen(yytext) - 1] = '\0'; if (insert_id(yytext + 1,0)) return -1; }
1374+ ;
1375 number : NUMBER
1376 { $$ = strtoul(yytext,NULL,0); }
1377 ;
1378diff --git a/libqpol/src/policy_scan.l b/libqpol/src/policy_scan.l
1379index 75485f3..30203cd 100644
1380--- a/libqpol/src/policy_scan.l
1381+++ b/libqpol/src/policy_scan.l
1382@@ -235,6 +235,7 @@ POLICYCAP { return(POLICYCAP); }
1383 permissive |
1384 PERMISSIVE { return(PERMISSIVE); }
1385 "/"({alnum}|[_\.\-/])* { return(PATH); }
1386+\"({alnum}|[_\.\-])+\" { return(FILENAME); }
1387 {letter}({alnum}|[_\-])*([\.]?({alnum}|[_\-]))* { return(IDENTIFIER); }
1388 {digit}+|0x{hexval}+ { return(NUMBER); }
1389 {digit}{1,3}(\.{digit}{1,3}){3} { return(IPV4_ADDR); }
1390diff --git a/secmds/sesearch.c b/secmds/sesearch.c
1391index ec0315f..e44b3bc 100644
1392--- a/secmds/sesearch.c
1393+++ b/secmds/sesearch.c
1394@@ -575,6 +575,95 @@ static void print_te_results(const apol_policy_t * policy, const options_t * opt
1395 free(expr);
1396 }
1397
1398+static int perform_ft_query(const apol_policy_t * policy, const options_t * opt, apol_vector_t ** v)
1399+{
1400+ apol_filename_trans_query_t *ftq = NULL;
1401+ int error = 0;
1402+
1403+ if (!policy || !opt || !v) {
1404+ ERR(policy, "%s", strerror(EINVAL));
1405+ errno = EINVAL;
1406+ return -1;
1407+ }
1408+
1409+ if (!opt->type == QPOL_RULE_TYPE_TRANS && !opt->all) {
1410+ *v = NULL;
1411+ return 0; /* no search to do */
1412+ }
1413+
1414+ ftq = apol_filename_trans_query_create();
1415+ if (!ftq) {
1416+ ERR(policy, "%s", strerror(ENOMEM));
1417+ errno = ENOMEM;
1418+ return -1;
1419+ }
1420+
1421+ apol_filename_trans_query_set_regex(policy, ftq, opt->useregex);
1422+ if (opt->src_name) {
1423+ if (apol_filename_trans_query_set_source(policy, ftq, opt->src_name)) {
1424+ error = errno;
1425+ goto err;
1426+ }
1427+ }
1428+ if (opt->tgt_name) {
1429+ if (apol_filename_trans_query_set_target(policy, ftq, opt->tgt_name, opt->indirect)) {
1430+ error = errno;
1431+ goto err;
1432+ }
1433+ }
1434+
1435+ if (apol_filename_trans_get_by_query(policy, ftq, v)) {
1436+ error = errno;
1437+ goto err;
1438+ }
1439+
1440+ apol_filename_trans_query_destroy(&ftq);
1441+ return 0;
1442+
1443+ err:
1444+ apol_vector_destroy(v);
1445+ apol_filename_trans_query_destroy(&ftq);
1446+ ERR(policy, "%s", strerror(error));
1447+ errno = error;
1448+ return -1;
1449+}
1450+
1451+static void print_ft_results(const apol_policy_t * policy, const options_t * opt, const apol_vector_t * v)
1452+{
1453+ qpol_policy_t *q = apol_policy_get_qpol(policy);
1454+ size_t i, num_rules = 0;
1455+ const qpol_filename_trans_t *rule = NULL;
1456+ char *tmp = NULL, *rule_str = NULL, *expr = NULL;
1457+ char enable_char = ' ', branch_char = ' ';
1458+ qpol_iterator_t *iter = NULL;
1459+ const qpol_cond_t *cond = NULL;
1460+ uint32_t enabled = 0, list = 0;
1461+
1462+ if (!(num_rules = apol_vector_get_size(v)))
1463+ goto cleanup;
1464+
1465+ fprintf(stdout, "Found %zd named file transition rules:\n", num_rules);
1466+
1467+ for (i = 0; i < num_rules; i++) {
1468+ enable_char = branch_char = ' ';
1469+ if (!(rule = apol_vector_get_element(v, i)))
1470+ goto cleanup;
1471+
1472+ if (!(rule_str = apol_filename_trans_render(policy, rule)))
1473+ goto cleanup;
1474+ fprintf(stdout, "%s %s\n", rule_str, expr ? expr : "");
1475+ free(rule_str);
1476+ rule_str = NULL;
1477+ free(expr);
1478+ expr = NULL;
1479+ }
1480+
1481+ cleanup:
1482+ free(tmp);
1483+ free(rule_str);
1484+ free(expr);
1485+}
1486+
1487 static int perform_ra_query(const apol_policy_t * policy, const options_t * opt, apol_vector_t ** v)
1488 {
1489 apol_role_allow_query_t *raq = NULL;
1490@@ -1128,6 +1217,18 @@ int main(int argc, char **argv)
1491 print_te_results(policy, &cmd_opts, v);
1492 fprintf(stdout, "\n");
1493 }
1494+
1495+ if (cmd_opts.all || cmd_opts.type == QPOL_RULE_TYPE_TRANS) {
1496+ apol_vector_destroy(&v);
1497+ if (perform_ft_query(policy, &cmd_opts, &v)) {
1498+ rt = 1;
1499+ goto cleanup;
1500+ }
1501+
1502+ print_ft_results(policy, &cmd_opts, v);
1503+ fprintf(stdout, "\n");
1504+ }
1505+
1506 apol_vector_destroy(&v);
1507 if (perform_ra_query(policy, &cmd_opts, &v)) {
1508 rt = 1;
1509--
15101.7.5.4
1511
diff --git a/recipes-security/setools/setools/setools-Don-t-build-python-bindings-if-disabled.patch b/recipes-security/setools/setools/setools-Don-t-build-python-bindings-if-disabled.patch
new file mode 100644
index 0000000..9a93d86
--- /dev/null
+++ b/recipes-security/setools/setools/setools-Don-t-build-python-bindings-if-disabled.patch
@@ -0,0 +1,29 @@
1From 5bf63cd7d9c2af5648b705784a5990414de64a3b Mon Sep 17 00:00:00 2001
2From: Xin Ouyang <Xin.Ouyang@windriver.com>
3Date: Wed, 7 Mar 2012 18:13:00 +0800
4Subject: [PATCH] setools: Don't build python bindings if disabled.
5
6---
7 Makefile.am | 6 +++++-
8 1 files changed, 5 insertions(+), 1 deletions(-)
9
10diff --git a/Makefile.am b/Makefile.am
11index 176c8ea..d33c65c 100644
12--- a/Makefile.am
13+++ b/Makefile.am
14@@ -10,7 +10,11 @@ if BUILD_GUI
15 endif
16 # sediffx is also built conditionally, from sediffx/Makefile.am
17
18-SUBDIRS = libqpol libapol libsefs libpoldiff libseaudit secmds sechecker sediff man packages debian $(MAYBE_APOL) $(MAYBE_GUI) python
19+if DO_SWIGIFY_PYTHON
20+ MAYBE_PY = python
21+endif
22+
23+SUBDIRS = libqpol libapol libsefs libpoldiff libseaudit secmds sechecker sediff man packages debian $(MAYBE_APOL) $(MAYBE_GUI) $(MAYBE_PY)
24
25 #old indent opts
26 #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
27--
281.7.5.4
29
diff --git a/recipes-security/setools/setools/setools-Don-t-check-selinux-policies-if-disabled.patch b/recipes-security/setools/setools/setools-Don-t-check-selinux-policies-if-disabled.patch
new file mode 100644
index 0000000..ed841e8
--- /dev/null
+++ b/recipes-security/setools/setools/setools-Don-t-check-selinux-policies-if-disabled.patch
@@ -0,0 +1,25 @@
1From 7515aa80e7ead8d3016ea161e5d0eb9c59399278 Mon Sep 17 00:00:00 2001
2From: Xin Ouyang <Xin.Ouyang@windriver.com>
3Date: Wed, 7 Mar 2012 14:36:19 +0800
4Subject: [PATCH] setools: Don't check selinux policies if disabled.
5
6---
7 configure.ac | 2 +-
8 1 files changed, 1 insertions(+), 1 deletions(-)
9
10diff --git a/configure.ac b/configure.ac
11index e1db271..899e5e9 100644
12--- a/configure.ac
13+++ b/configure.ac
14@@ -390,7 +390,7 @@ if test "x${enable_selinux_check}" = "xyes"; then
15 use_selinux=yes
16 fi
17 else
18- use_selinux=yes
19+ use_selinux=no
20 fi
21
22 AC_CACHE_SAVE
23--
241.7.5.4
25
diff --git a/recipes-security/setools/setools/setools-Fix-man-pages-and-getoptions.patch b/recipes-security/setools/setools/setools-Fix-man-pages-and-getoptions.patch
new file mode 100644
index 0000000..455da1e
--- /dev/null
+++ b/recipes-security/setools/setools/setools-Fix-man-pages-and-getoptions.patch
@@ -0,0 +1,80 @@
1From ecaccf49ee95fe2c3a57a0d2184aaec98a967172 Mon Sep 17 00:00:00 2001
2From: Xin Ouyang <Xin.Ouyang@windriver.com>
3Date: Wed, 7 Mar 2012 10:53:36 +0800
4Subject: [PATCH 3/7] setools: Fix man pages and getoptions
5
6Integrated from Fedora:
7https://community.dev.fedoraproject.org/packages/setools/sources/patches/
8---
9 man/replcon.1 | 2 ++
10 man/seinfo.1 | 6 +++++-
11 seaudit/seaudit-report.c | 2 +-
12 sediff/sediff.c | 2 +-
13 4 files changed, 9 insertions(+), 3 deletions(-)
14
15diff --git a/man/replcon.1 b/man/replcon.1
16index 8aca08a..478dc51 100644
17--- a/man/replcon.1
18+++ b/man/replcon.1
19@@ -44,6 +44,8 @@ Search for files which include PATH.
20 .IP "-c CLASS, --class=CLASS"
21 Search only files of object class CLASS.
22 .SH OPTIONS
23+.IP "-R, --regex"
24+Enable regular expressions
25 .IP "-v, --verbose"
26 Display context info during replacement.
27 .IP "-h, --help"
28diff --git a/man/seinfo.1 b/man/seinfo.1
29index 8612119..6bc17db 100644
30--- a/man/seinfo.1
31+++ b/man/seinfo.1
32@@ -76,6 +76,10 @@ There is no expanded information for this component.
33 .IP "--nodecon[=ADDR]"
34 Print a list of node contexts or, if ADDR is provided, print the statement for the node with address ADDR.
35 There is no expanded information for this component.
36+.IP "--polcap"
37+Print policy capabilities.
38+.IP "--permissive"
39+Print permissive types.
40 .IP "--portcon[=PORT]"
41 Print a list of port contexts or, if PORT is provided, print the statement for port PORT.
42 There is no expanded information for this component.
43@@ -93,7 +97,7 @@ These details include the types assigned to an attribute or role and the permiss
44 This option is not available for all component types; see the description of each component for the details this option will provide.
45 .IP "--stats"
46 Print policy statistics including policy type and version information and counts of all components and rules.
47-.IP "-l"
48+.IP "-l, --line-breaks"
49 Print line breaks when displaying constraint statements.
50 .IP "-h, --help"
51 Print help information and exit.
52diff --git a/seaudit/seaudit-report.c b/seaudit/seaudit-report.c
53index af3c6fb..d436c18 100644
54--- a/seaudit/seaudit-report.c
55+++ b/seaudit/seaudit-report.c
56@@ -100,7 +100,7 @@ static void seaudit_report_info_usage(const char *program_name, int brief)
57 printf(" -s, --stdin read log data from standard input\n");
58 printf(" -m, --malformed include malformed log messages\n");
59 printf(" -o FILE, --output=FILE output to FILE\n");
60- printf(" --config=FILE read configuration from FILE\n");
61+ printf(" -c FILE, --config=FILE read configuration from FILE\n");
62 printf(" --html set output format to HTML\n");
63 printf(" --stylesheet=FILE HTML style sheet for formatting HTML report\n");
64 printf(" (ignored if --html is not given)\n");
65diff --git a/sediff/sediff.c b/sediff/sediff.c
66index 6022775..341c650 100644
67--- a/sediff/sediff.c
68+++ b/sediff/sediff.c
69@@ -420,7 +420,7 @@ int main(int argc, char **argv)
70 poldiff_t *diff = NULL;
71 size_t total = 0;
72
73- while ((optc = getopt_long(argc, argv, "ctarubANDLMCRqhV", longopts, NULL)) != -1) {
74+ while ((optc = getopt_long(argc, argv, "ctarubAqhV", longopts, NULL)) != -1) {
75 switch (optc) {
76 case 0:
77 break;
78--
791.7.5.4
80
diff --git a/recipes-security/setools/setools/setools-Fix-output-to-match-policy-lines.patch b/recipes-security/setools/setools/setools-Fix-output-to-match-policy-lines.patch
new file mode 100644
index 0000000..c397aa6
--- /dev/null
+++ b/recipes-security/setools/setools/setools-Fix-output-to-match-policy-lines.patch
@@ -0,0 +1,36 @@
1From 81f2221ab707ca8d5e204b0f9be61d537888e439 Mon Sep 17 00:00:00 2001
2From: Xin Ouyang <Xin.Ouyang@windriver.com>
3Date: Wed, 7 Mar 2012 11:03:00 +0800
4Subject: [PATCH 7/7] setools: Fix output to match policy lines
5
6Integrated from Fedora:
7https://community.dev.fedoraproject.org/packages/setools/sources/patches/
8---
9 libapol/src/ftrule-query.c | 4 ++--
10 1 files changed, 2 insertions(+), 2 deletions(-)
11
12diff --git a/libapol/src/ftrule-query.c b/libapol/src/ftrule-query.c
13index 9c7a23b..1d5f5c8 100644
14--- a/libapol/src/ftrule-query.c
15+++ b/libapol/src/ftrule-query.c
16@@ -282,7 +282,7 @@ char *apol_filename_trans_render(const apol_policy_t * policy, const qpol_filena
17 error = errno;
18 goto err;
19 }
20- if (apol_str_appendf(&tmp, &tmp_sz, "transition_type %s ", tmp_name)) {
21+ if (apol_str_appendf(&tmp, &tmp_sz, "type_transition %s ", tmp_name)) {
22 error = errno;
23 ERR(policy, "%s", strerror(error));
24 goto err;
25@@ -338,7 +338,7 @@ char *apol_filename_trans_render(const apol_policy_t * policy, const qpol_filena
26 goto err;
27 }
28
29- if (apol_str_appendf(&tmp, &tmp_sz, " %s", tmp_name)) {
30+ if (apol_str_appendf(&tmp, &tmp_sz, " \"%s\"", tmp_name)) {
31 error = errno;
32 ERR(policy, "%s", strerror(error));
33 goto err;
34--
351.7.5.4
36
diff --git a/recipes-security/setools/setools/setools-Fix-python-setools-Makefile.am-for-cross.patch b/recipes-security/setools/setools/setools-Fix-python-setools-Makefile.am-for-cross.patch
new file mode 100644
index 0000000..c4d062a
--- /dev/null
+++ b/recipes-security/setools/setools/setools-Fix-python-setools-Makefile.am-for-cross.patch
@@ -0,0 +1,33 @@
1From 7d386c429202b393aa4ca281a11b5e1f2259b109 Mon Sep 17 00:00:00 2001
2From: Xin Ouyang <Xin.Ouyang@windriver.com>
3Date: Wed, 7 Mar 2012 15:43:41 +0800
4Subject: [PATCH] setools: Fix python/setools/Makefile.am for cross.
5
6---
7 python/setools/Makefile.am | 6 +++---
8 1 files changed, 3 insertions(+), 3 deletions(-)
9
10diff --git a/python/setools/Makefile.am b/python/setools/Makefile.am
11index c4635fb..80aa385 100644
12--- a/python/setools/Makefile.am
13+++ b/python/setools/Makefile.am
14@@ -22,13 +22,13 @@ sesearch_SOURCES = sesearch.c
15 python-build: sesearch.c seinfo.c
16 @mkdir -p setools
17 @cp __init__.py setools
18- LIBS="$(QPOL_LIB_FLAG) $(APOL_LIB_FLAG)" INCLUDES="$(QPOL_CFLAGS) $(APOL_CFLAGS)" $(PYTHON) setup.py build
19+ CC="${CC}" LDSHARED="$(CC) -shared" LIBS="$(QPOL_LIB_FLAG) $(APOL_LIB_FLAG) $(PYTHON_LDFLAGS)" INCLUDES="$(QPOL_CFLAGS) $(APOL_CFLAGS) $(PYTHON_CPPFLAGS)" ${PYTHON} setup.py build
20
21 install-exec-hook:
22- $(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
23+ $(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --install-lib=$(PYTHON_SITE_PKG)`
24
25 uninstall-hook:
26- $(PYTHON) setup.py uninstall `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
27+ $(PYTHON) setup.py uninstall `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --install-lib=$(PYTHON_SITE_PKG)`
28
29 clean-local:
30 $(PYTHON) setup.py clean -a
31--
321.7.5.4
33
diff --git a/recipes-security/setools/setools/setools-Fix-sepol-calls-to-work-with-latest-libsepol.patch b/recipes-security/setools/setools/setools-Fix-sepol-calls-to-work-with-latest-libsepol.patch
new file mode 100644
index 0000000..8519ab2
--- /dev/null
+++ b/recipes-security/setools/setools/setools-Fix-sepol-calls-to-work-with-latest-libsepol.patch
@@ -0,0 +1,36 @@
1From 16d3a0b41273be4289f70d1d63fb983721bb60c0 Mon Sep 17 00:00:00 2001
2From: Xin Ouyang <Xin.Ouyang@windriver.com>
3Date: Wed, 7 Mar 2012 10:54:55 +0800
4Subject: [PATCH 4/7] setools: Fix sepol calls to work with latest libsepol
5
6Integrated from Fedora:
7https://community.dev.fedoraproject.org/packages/setools/sources/patches/
8---
9 configure.ac | 4 ++--
10 1 files changed, 2 insertions(+), 2 deletions(-)
11
12diff --git a/configure.ac b/configure.ac
13index e837e03..3c11e23 100644
14--- a/configure.ac
15+++ b/configure.ac
16@@ -505,7 +505,7 @@ AC_COMPILE_IFELSE(
17 [AC_LANG_SOURCE([
18 #include <sepol/policydb/expand.h>
19 int main () {
20- return role_set_expand(NULL, NULL, NULL, NULL);
21+ return role_set_expand(NULL, NULL, NULL, NULL, NULL);
22 }])],
23 sepol_new_user_role_mapping="yes",
24 sepol_new_user_role_mapping="no")
25@@ -541,7 +541,7 @@ if test ${sepol_check_boolmap} = "yes"; then
26 [AC_LANG_SOURCE([
27 #include <sepol/policydb/expand.h>
28 int main () {
29- return expand_module_avrules(NULL, NULL, NULL, NULL, NULL, 0, 0);
30+ return expand_module_avrules(NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0);
31 }])],
32 AC_MSG_RESULT([yes]),
33 AC_MSG_ERROR([this version of libsepol is incompatible with SETools]))
34--
351.7.5.4
36
diff --git a/recipes-security/setools/setools/setools-Fix-test-bug-for-unary-operator.patch b/recipes-security/setools/setools/setools-Fix-test-bug-for-unary-operator.patch
new file mode 100644
index 0000000..7b6e539
--- /dev/null
+++ b/recipes-security/setools/setools/setools-Fix-test-bug-for-unary-operator.patch
@@ -0,0 +1,25 @@
1From 5f574dc0fb68fe07c5b611ca34c01b8484735aab Mon Sep 17 00:00:00 2001
2From: Xin Ouyang <Xin.Ouyang@windriver.com>
3Date: Wed, 7 Mar 2012 14:47:44 +0800
4Subject: [PATCH] setools: Fix "test" bug for unary operator.
5
6configure: line 22969: test: =: unary operator expected
7---
8 configure.ac | 1 +
9 1 files changed, 1 insertions(+), 0 deletions(-)
10
11diff --git a/configure.ac b/configure.ac
12index 899e5e9..6854c69 100644
13--- a/configure.ac
14+++ b/configure.ac
15@@ -233,6 +233,7 @@ if test ${do_swigify} = "yes"; then
16 AC_PROG_SWIG(2.0.0)
17 fi
18 build_apol=yes
19+do_swigify_tcl=no
20 AC_ARG_ENABLE(swig-tcl,
21 AC_HELP_STRING([--enable-swig-tcl],
22 [build SWIG interfaces for Tcl (default)]),
23--
241.7.5.4
25
diff --git a/recipes-security/setools/setools/setools-Remove-unused-variables.patch b/recipes-security/setools/setools/setools-Remove-unused-variables.patch
new file mode 100644
index 0000000..f991819
--- /dev/null
+++ b/recipes-security/setools/setools/setools-Remove-unused-variables.patch
@@ -0,0 +1,279 @@
1From d8a4502fae7118796558e523a6dc0a6a5f9adec9 Mon Sep 17 00:00:00 2001
2From: Xin Ouyang <Xin.Ouyang@windriver.com>
3Date: Wed, 7 Mar 2012 11:02:10 +0800
4Subject: [PATCH 6/7] setools: Remove unused variables
5
6Integrated from Fedora:
7https://community.dev.fedoraproject.org/packages/setools/sources/patches/
8---
9 libapol/src/ftrule-query.c | 11 ++----
10 libqpol/src/ftrule_query.c | 2 -
11 secmds/sesearch.c | 86 +++++++++++++++++++++++++++++++++-----------
12 3 files changed, 68 insertions(+), 31 deletions(-)
13
14diff --git a/libapol/src/ftrule-query.c b/libapol/src/ftrule-query.c
15index dc248de..9c7a23b 100644
16--- a/libapol/src/ftrule-query.c
17+++ b/libapol/src/ftrule-query.c
18@@ -45,14 +45,11 @@ struct apol_filename_trans_query
19 int apol_filename_trans_get_by_query(const apol_policy_t * p, const apol_filename_trans_query_t * t, apol_vector_t ** v)
20 {
21 apol_vector_t *source_list = NULL, *target_list = NULL, *class_list = NULL, *default_list = NULL;
22- int retval = -1, source_as_any = 0, is_regex = 0, append_filename_trans;
23- char *bool_name = NULL;
24+ int retval = -1, source_as_any = 0, is_regex = 0;
25 *v = NULL;
26- unsigned int flags = 0;
27- qpol_iterator_t *iter = NULL, *type_iter = NULL;
28+ qpol_iterator_t *iter = NULL;
29
30 if (t != NULL) {
31- flags = t->flags;
32 is_regex = t->flags & APOL_QUERY_REGEX;
33 if (t->source != NULL &&
34 (source_list =
35@@ -104,7 +101,7 @@ int apol_filename_trans_get_by_query(const apol_policy_t * p, const apol_filenam
36 if (qpol_iterator_get_item(iter, (void **)&filename_trans) < 0) {
37 goto cleanup;
38 }
39- int match_source = 0, match_target = 0, match_default = 0, match_bool = 0;
40+ int match_source = 0, match_target = 0, match_default = 0;
41 size_t i;
42
43 if (source_list == NULL) {
44@@ -265,10 +262,8 @@ char *apol_filename_trans_render(const apol_policy_t * policy, const qpol_filena
45 {
46 char *tmp = NULL;
47 const char *tmp_name = NULL;
48- const char *filename_trans_type_str;
49 int error = 0;
50 size_t tmp_sz = 0;
51- uint32_t filename_trans_type = 0;
52 const qpol_type_t *type = NULL;
53 const qpol_class_t *obj_class = NULL;
54
55diff --git a/libqpol/src/ftrule_query.c b/libqpol/src/ftrule_query.c
56index d6db848..3148d30 100644
57--- a/libqpol/src/ftrule_query.c
58+++ b/libqpol/src/ftrule_query.c
59@@ -254,7 +254,6 @@ int qpol_filename_trans_get_default_type(const qpol_policy_t * policy, const qpo
60
61 int qpol_filename_trans_get_filename(const qpol_policy_t * policy, const qpol_filename_trans_t * rule, const char ** name)
62 {
63- policydb_t *db = NULL;
64 filename_trans_t *ft = NULL;
65
66 if (name) {
67@@ -267,7 +266,6 @@ int qpol_filename_trans_get_filename(const qpol_policy_t * policy, const qpol_fi
68 return STATUS_ERR;
69 }
70
71- db = &policy->p->p;
72 ft = (filename_trans_t *) rule;
73
74 *name = ft->name;
75diff --git a/secmds/sesearch.c b/secmds/sesearch.c
76index e44b3bc..319ffe7 100644
77--- a/secmds/sesearch.c
78+++ b/secmds/sesearch.c
79@@ -72,6 +72,7 @@ static struct option const longopts[] = {
80
81 {"source", required_argument, NULL, 's'},
82 {"target", required_argument, NULL, 't'},
83+ {"default", required_argument, NULL, 'D'},
84 {"role_source", required_argument, NULL, EXPR_ROLE_SOURCE},
85 {"role_target", required_argument, NULL, EXPR_ROLE_TARGET},
86 {"class", required_argument, NULL, 'c'},
87@@ -92,6 +93,7 @@ typedef struct options
88 {
89 char *src_name;
90 char *tgt_name;
91+ char *default_name;
92 char *src_role_name;
93 char *tgt_role_name;
94 char *class_name;
95@@ -293,7 +295,8 @@ static void print_syn_av_results(const apol_policy_t * policy, const options_t *
96 tmp = apol_cond_expr_render(policy, cond);
97 enable_char = (enabled ? 'E' : 'D');
98 branch_char = ((is_true && enabled) || (!is_true && !enabled) ? 'T' : 'F');
99- asprintf(&expr, "[ %s ]", tmp);
100+ if (asprintf(&expr, "[ %s ]", tmp) < 0)
101+ goto cleanup;
102 free(tmp);
103 tmp = NULL;
104 if (!expr)
105@@ -356,7 +359,8 @@ static void print_av_results(const apol_policy_t * policy, const options_t * opt
106 qpol_iterator_destroy(&iter);
107 enable_char = (enabled ? 'E' : 'D');
108 branch_char = (list ? 'T' : 'F');
109- asprintf(&expr, "[ %s ]", tmp);
110+ if (asprintf(&expr, "[ %s ]", tmp) < 0)
111+ goto cleanup;
112 free(tmp);
113 tmp = NULL;
114 if (!expr)
115@@ -488,7 +492,8 @@ static void print_syn_te_results(const apol_policy_t * policy, const options_t *
116 tmp = apol_cond_expr_render(policy, cond);
117 enable_char = (enabled ? 'E' : 'D');
118 branch_char = ((is_true && enabled) || (!is_true && !enabled) ? 'T' : 'F');
119- asprintf(&expr, "[ %s ]", tmp);
120+ if (asprintf(&expr, "[ %s ]", tmp) < 0)
121+ goto cleanup;
122 free(tmp);
123 tmp = NULL;
124 if (!expr)
125@@ -553,7 +558,8 @@ static void print_te_results(const apol_policy_t * policy, const options_t * opt
126 qpol_iterator_destroy(&iter);
127 enable_char = (enabled ? 'E' : 'D');
128 branch_char = (list ? 'T' : 'F');
129- asprintf(&expr, "[ %s ]", tmp);
130+ if (asprintf(&expr, "[ %s ]", tmp) < 0)
131+ goto cleanup;
132 free(tmp);
133 tmp = NULL;
134 if (!expr)
135@@ -586,7 +592,7 @@ static int perform_ft_query(const apol_policy_t * policy, const options_t * opt,
136 return -1;
137 }
138
139- if (!opt->type == QPOL_RULE_TYPE_TRANS && !opt->all) {
140+ if (!opt->type && !opt->all) {
141 *v = NULL;
142 return 0; /* no search to do */
143 }
144@@ -600,17 +606,44 @@ static int perform_ft_query(const apol_policy_t * policy, const options_t * opt,
145
146 apol_filename_trans_query_set_regex(policy, ftq, opt->useregex);
147 if (opt->src_name) {
148- if (apol_filename_trans_query_set_source(policy, ftq, opt->src_name)) {
149+ if (apol_filename_trans_query_set_source(policy, ftq, opt->src_name, opt->indirect)) {
150 error = errno;
151 goto err;
152 }
153 }
154+
155 if (opt->tgt_name) {
156 if (apol_filename_trans_query_set_target(policy, ftq, opt->tgt_name, opt->indirect)) {
157 error = errno;
158 goto err;
159 }
160 }
161+ if (opt->default_name) {
162+ if (apol_filename_trans_query_set_default(policy, ftq, opt->default_name)) {
163+ error = errno;
164+ goto err;
165+ }
166+ }
167+
168+ if (opt->class_name) {
169+ if (opt->class_vector == NULL) {
170+ if (apol_filename_trans_query_append_class(policy, ftq, opt->class_name)) {
171+ error = errno;
172+ goto err;
173+ }
174+ } else {
175+ for (size_t i = 0; i < apol_vector_get_size(opt->class_vector); ++i) {
176+ char *class_name;
177+ class_name = apol_vector_get_element(opt->class_vector, i);
178+ if (!class_name)
179+ continue;
180+ if (apol_filename_trans_query_append_class(policy, ftq, class_name)) {
181+ error = errno;
182+ goto err;
183+ }
184+ }
185+ }
186+ }
187
188 if (apol_filename_trans_get_by_query(policy, ftq, v)) {
189 error = errno;
190@@ -630,37 +663,36 @@ static int perform_ft_query(const apol_policy_t * policy, const options_t * opt,
191
192 static void print_ft_results(const apol_policy_t * policy, const options_t * opt, const apol_vector_t * v)
193 {
194- qpol_policy_t *q = apol_policy_get_qpol(policy);
195- size_t i, num_rules = 0;
196- const qpol_filename_trans_t *rule = NULL;
197- char *tmp = NULL, *rule_str = NULL, *expr = NULL;
198+ size_t i, num_filename_trans = 0;
199+ const qpol_filename_trans_t *filename_trans = NULL;
200+ char *tmp = NULL, *filename_trans_str = NULL, *expr = NULL;
201 char enable_char = ' ', branch_char = ' ';
202 qpol_iterator_t *iter = NULL;
203 const qpol_cond_t *cond = NULL;
204 uint32_t enabled = 0, list = 0;
205
206- if (!(num_rules = apol_vector_get_size(v)))
207+ if (!(num_filename_trans = apol_vector_get_size(v)))
208 goto cleanup;
209
210- fprintf(stdout, "Found %zd named file transition rules:\n", num_rules);
211+ fprintf(stdout, "Found %zd named file transition filename_trans:\n", num_filename_trans);
212
213- for (i = 0; i < num_rules; i++) {
214+ for (i = 0; i < num_filename_trans; i++) {
215 enable_char = branch_char = ' ';
216- if (!(rule = apol_vector_get_element(v, i)))
217+ if (!(filename_trans = apol_vector_get_element(v, i)))
218 goto cleanup;
219
220- if (!(rule_str = apol_filename_trans_render(policy, rule)))
221+ if (!(filename_trans_str = apol_filename_trans_render(policy, filename_trans)))
222 goto cleanup;
223- fprintf(stdout, "%s %s\n", rule_str, expr ? expr : "");
224- free(rule_str);
225- rule_str = NULL;
226+ fprintf(stdout, "%s %s\n", filename_trans_str, expr ? expr : "");
227+ free(filename_trans_str);
228+ filename_trans_str = NULL;
229 free(expr);
230 expr = NULL;
231 }
232
233 cleanup:
234 free(tmp);
235- free(rule_str);
236+ free(filename_trans_str);
237 free(expr);
238 }
239
240@@ -930,7 +962,7 @@ int main(int argc, char **argv)
241
242 memset(&cmd_opts, 0, sizeof(cmd_opts));
243 cmd_opts.indirect = true;
244- while ((optc = getopt_long(argc, argv, "ATs:t:c:p:b:dRnSChV", longopts, NULL)) != -1) {
245+ while ((optc = getopt_long(argc, argv, "ATs:t:c:p:b:dD:RnSChV", longopts, NULL)) != -1) {
246 switch (optc) {
247 case 0:
248 break;
249@@ -946,6 +978,18 @@ int main(int argc, char **argv)
250 exit(1);
251 }
252 break;
253+ case 'D': /* source */
254+ if (optarg == 0) {
255+ usage(argv[0], 1);
256+ printf("Missing source default type for -D (--default)\n");
257+ exit(1);
258+ }
259+ cmd_opts.default_name = strdup(optarg);
260+ if (!cmd_opts.default_name) {
261+
262+ exit(1);
263+ }
264+ break;
265 case 't': /* target */
266 if (optarg == 0) {
267 usage(argv[0], 1);
268@@ -1218,7 +1262,7 @@ int main(int argc, char **argv)
269 fprintf(stdout, "\n");
270 }
271
272- if (cmd_opts.all || cmd_opts.type == QPOL_RULE_TYPE_TRANS) {
273+ if (cmd_opts.all || cmd_opts.type) {
274 apol_vector_destroy(&v);
275 if (perform_ft_query(policy, &cmd_opts, &v)) {
276 rt = 1;
277--
2781.7.5.4
279
diff --git a/recipes-security/setools/setools/setools-configure-ac.patch b/recipes-security/setools/setools/setools-configure-ac.patch
new file mode 100644
index 0000000..5b8e440
--- /dev/null
+++ b/recipes-security/setools/setools/setools-configure-ac.patch
@@ -0,0 +1,107 @@
1---
2 configure.ac | 37 ++++++++++++++-----------------------
3 1 file changed, 14 insertions(+), 23 deletions(-)
4
5--- a/configure.ac
6+++ b/configure.ac
7@@ -216,9 +216,6 @@
8 do_swigify_java=yes
9 do_swigify=yes
10 fi
11-
12-AM_PATH_PYTHON(2.7)
13-
14 AC_ARG_ENABLE(swig-python,
15 AC_HELP_STRING([--enable-swig-python],
16 [build SWIG interfaces for Python]),
17@@ -227,6 +224,7 @@
18 if test ${do_swigify} = no; then
19 AC_PROG_SWIG(2.0.0)
20 fi
21+ AM_PATH_PYTHON(2.7)
22 SWIG_PYTHON
23 do_swigify_python=yes
24 do_swigify=yes
25@@ -411,32 +409,19 @@
26 selinux_devel="/usr")
27 sepol_devel_incdir="${sepol_devel}/include"
28 selinux_devel_incdir="${selinux_devel}/include"
29-dnl if /lib64 exists then use that directory, otherwise revert to just /lib
30-for dir in lib64 lib ; do
31- sepol_devel_libdir="${sepol_devel}/${dir}"
32- if test -f ${sepol_devel_libdir}/libsepol.so ; then
33- break
34- fi
35-done
36-for dir in lib64 lib ; do
37- selinux_devel_libdir="${selinux_devel}/${dir}"
38- if test -f ${selinux_devel_libdir}/libselinux.so ; then
39- break
40- fi
41-done
42+dnl We pass in sepol_devel of usr/lib{32/64}/.., dirname strips the ..
43+sepol_devel_libdir=`dirname ${sepol_devel}`
44+selinux_devel_libdir=`dirname ${selinux_devel}`
45 AC_MSG_CHECKING([for sepol/sepol.h])
46 selinux_save_CFLAGS="${CFLAGS}"
47 selinux_save_CPPFLAGS="${CPPFLAGS}"
48 CFLAGS="${CFLAGS} -I${sepol_devel_incdir} -I${selinux_devel_incdir}"
49 CPPFLAGS="${CPPFLAGS} -I${sepol_devel_incdir} -I${selinux_devel_incdir}"
50 AC_CHECK_HEADER([sepol/sepol.h], , AC_MSG_ERROR([could not find sepol headers at $sepol_devel_incdir - make sure libsepol-devel is installed]))
51-AC_CHECK_LIB([sepol], [sepol_policydb_read], ,
52- AC_MSG_ERROR([could not find libsepol at $sepol_devel_libdir]))
53+LIBS="-lsepol $LIBS"
54 AC_CHECK_HEADER([selinux/selinux.h], , AC_MSG_ERROR([could not find selinux headers at $selinux_devel_incdir - make sure libselinux-devel is installed]))
55 AC_CHECK_HEADER([selinux/context.h], , AC_MSG_ERROR([could not find selinux headers at $selinux_devel_incdir - make sure libselinux-devel is installed]))
56-AC_CHECK_LIB([selinux], [selinux_policy_root], ,
57-AC_MSG_ERROR([could not find libselinux at $selinux_devel_libdir]),
58- -lsepol)
59+LIBS="-lselinux $LIBS"
60 SELINUX_LIB_FLAG="-L${sepol_devel_libdir} -L${selinux_devel_libdir}"
61 CFLAGS="${selinux_save_CFLAGS}"
62 CPPFLAGS="${selinux_save_CPPFLAGS}"
63@@ -448,8 +433,6 @@
64 sepol_srcdir="")
65 if test "x${sepol_srcdir}" = "x"; then
66 sepol_srcdir=${sepol_devel_libdir}
67- AC_CHECK_FILE([${sepol_srcdir}/libsepol.a],,
68- AC_MSG_ERROR([make sure libsepol-static is installed]))
69 else
70 AC_MSG_CHECKING([for compatible sepol source tree])
71 sepol_version=${sepol_srcdir}/VERSION
72@@ -556,6 +539,7 @@
73 sepol_new_errcodes="yes",
74 sepol_new_errcodes="no")
75
76+if test x"${ac_cv_policydb_version_max}" = x ; then
77 AC_RUN_IFELSE(
78 [AC_LANG_SOURCE([
79 #include <sepol/policydb/policydb.h>
80@@ -571,6 +555,9 @@
81 }])],
82 sepol_policy_version_max=`cat conftest.data`,
83 AC_MSG_FAILURE([could not determine maximum libsepol policy version]))
84+else
85+ sepol_policy_version_max=${ac_cv_policydb_version_max}
86+fi
87 AC_DEFINE_UNQUOTED(SEPOL_POLICY_VERSION_MAX, ${sepol_policy_version_max}, [maximum policy version supported by libsepol])
88 CFLAGS="${sepol_save_CFLAGS}"
89 CPPFLAGS="${sepol_save_CPPFLAGS}"
90@@ -578,6 +565,7 @@
91 if test ${use_selinux} = "yes"; then
92 dnl Locate selinux policy root directory
93 AC_MSG_CHECKING([for selinux policy root])
94+ if test x"${ac_cv_selinux_policy_root}" = x ; then
95 changequote(<<<,>>>)dnl
96 cat > ./conftest.c <<EOF
97 #include <stdlib.h>
98@@ -596,6 +584,9 @@
99 CFLAGS="${SELINUX_CFLAGS} ${SELINUX_LIB_FLAG} -lselinux -lsepol ${CFLAGS}"
100 gcc ${CFLAGS} -o conftest conftest.c >&5
101 selinux_policy_dir=`./conftest`
102+ else
103+ selinux_policy_dir=${ac_cv_selinux_policy_root}
104+ fi
105 AC_MSG_RESULT(${selinux_policy_dir})
106 CFLAGS="${selinux_save_CFLAGS}"
107 fi
diff --git a/recipes-security/setools/setools/setools-configure-with-latest-libsepol.patch b/recipes-security/setools/setools/setools-configure-with-latest-libsepol.patch
new file mode 100644
index 0000000..84ac3dc
--- /dev/null
+++ b/recipes-security/setools/setools/setools-configure-with-latest-libsepol.patch
@@ -0,0 +1,33 @@
1From 2b58d92add64b53b16cbb438e7b69e85d046afd1 Mon Sep 17 00:00:00 2001
2From: Dan Walsh <dwalsh@redhat.com>
3Date: Tue, 20 Sep 2011 15:46:38 -0400
4Subject: [PATCH 5/6] Fix sepol calls to work with latest libsepol
5
6---
7 configure.ac | 4 ++--
8 1 files changed, 2 insertions(+), 2 deletions(-)
9
10diff --git a/configure.ac b/configure.ac
11index e837e03..3c11e23 100644
12--- a/configure.ac
13+++ b/configure.ac
14@@ -505,7 +505,7 @@ AC_COMPILE_IFELSE(
15 [AC_LANG_SOURCE([
16 #include <sepol/policydb/expand.h>
17 int main () {
18- return role_set_expand(NULL, NULL, NULL, NULL);
19+ return role_set_expand(NULL, NULL, NULL, NULL, NULL);
20 }])],
21 sepol_new_user_role_mapping="yes",
22 sepol_new_user_role_mapping="no")
23@@ -541,7 +541,7 @@ if test ${sepol_check_boolmap} = "yes"; then
24 [AC_LANG_SOURCE([
25 #include <sepol/policydb/expand.h>
26 int main () {
27- return expand_module_avrules(NULL, NULL, NULL, NULL, NULL, 0, 0);
28+ return expand_module_avrules(NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0);
29 }])],
30 AC_MSG_RESULT([yes]),
31 AC_MSG_ERROR([this version of libsepol is incompatible with SETools]))
32--
331.7.6.2
diff --git a/recipes-security/setools/setools/setools-cross-ar.patch b/recipes-security/setools/setools/setools-cross-ar.patch
new file mode 100644
index 0000000..eba24c2
--- /dev/null
+++ b/recipes-security/setools/setools/setools-cross-ar.patch
@@ -0,0 +1,17 @@
1Use the specified $(AR), not "ar", for cross-compiling.
2
3---
4 libqpol/src/Makefile.am | 2 +-
5 1 file changed, 1 insertion(+), 1 deletion(-)
6
7--- a/libqpol/src/Makefile.am
8+++ b/libqpol/src/Makefile.am
9@@ -64,7 +64,7 @@
10 mkdir -p $@
11 rm -f $@/*
12 cp $< $@
13- (cd $@; ar x libsepol.a)
14+ (cd $@; $(AR) x libsepol.a)
15
16 $(qpolso_DATA): $(tmp_sepol) $(libqpol_so_OBJS) libqpol.map
17 $(CC) -shared -o $@ $(libqpol_so_OBJS) $(AM_LDFLAGS) $(LDFLAGS) -Wl,-soname,$(LIBQPOL_SONAME),--version-script=$(srcdir)/libqpol.map,-z,defs -Wl,--whole-archive $(sepol_srcdir)/libsepol.a -Wl,--no-whole-archive @SELINUX_LIB_FLAG@ -lselinux -lsepol -lbz2
diff --git a/recipes-security/setools/setools/setools-seinfo-should-exit-with-correct-errno.patch b/recipes-security/setools/setools/setools-seinfo-should-exit-with-correct-errno.patch
new file mode 100644
index 0000000..a9cec6e
--- /dev/null
+++ b/recipes-security/setools/setools/setools-seinfo-should-exit-with-correct-errno.patch
@@ -0,0 +1,134 @@
1From 65ff2020dd1119cf45ad4eb74e63b21fb8f63389 Mon Sep 17 00:00:00 2001
2From: Xin Ouyang <Xin.Ouyang@windriver.com>
3Date: Wed, 7 Mar 2012 10:48:07 +0800
4Subject: [PATCH 2/7] setools: seinfo should exit with correct errno.
5
6Integrated from Fedora:
7https://community.dev.fedoraproject.org/packages/setools/sources/patches/
8---
9 secmds/seinfo.c | 51 +++++++++++++++++++++++++++------------------------
10 1 files changed, 27 insertions(+), 24 deletions(-)
11
12diff --git a/secmds/seinfo.c b/secmds/seinfo.c
13index fdf23e9..3088f88 100644
14--- a/secmds/seinfo.c
15+++ b/secmds/seinfo.c
16@@ -827,7 +827,7 @@ static int print_sens(FILE * fp, const char *name, int expand, const apol_policy
17 */
18 static int print_cats(FILE * fp, const char *name, int expand, const apol_policy_t * policydb)
19 {
20- int retval = 0;
21+ int retval = -1;
22 apol_cat_query_t *query = NULL;
23 apol_vector_t *v = NULL;
24 const qpol_cat_t *cat_datum = NULL;
25@@ -911,9 +911,10 @@ static int print_fsuse(FILE * fp, const char *type, const apol_policy_t * policy
26 fprintf(fp, " %s\n", tmp);
27 free(tmp);
28 }
29- if (type && !apol_vector_get_size(v))
30+ if (type && !apol_vector_get_size(v)) {
31 ERR(policydb, "No fs_use statement for filesystem of type %s.", type);
32-
33+ goto cleanup;
34+ }
35 retval = 0;
36 cleanup:
37 apol_fs_use_query_destroy(&query);
38@@ -949,7 +950,6 @@ static int print_genfscon(FILE * fp, const char *type, const apol_policy_t * pol
39 ERR(policydb, "%s", strerror(ENOMEM));
40 goto cleanup;
41 }
42-
43 if (apol_genfscon_query_set_filesystem(policydb, query, type))
44 goto cleanup;
45 if (apol_genfscon_get_by_query(policydb, query, &v))
46@@ -967,8 +967,10 @@ static int print_genfscon(FILE * fp, const char *type, const apol_policy_t * pol
47 free(tmp);
48 }
49
50- if (type && !apol_vector_get_size(v))
51+ if (type && !apol_vector_get_size(v)) {
52 ERR(policydb, "No genfscon statement for filesystem of type %s.", type);
53+ goto cleanup;
54+ }
55
56 retval = 0;
57 cleanup:
58@@ -1646,6 +1648,7 @@ cleanup: // close and destroy iterators etc.
59
60 int main(int argc, char **argv)
61 {
62+ int rc = 0;
63 int classes, types, attribs, roles, users, all, expand, stats, rt, optc, isids, bools, sens, cats, fsuse, genfs, netif,
64 node, port, permissives, polcaps, constrain, linebreaks;
65 apol_policy_t *policydb = NULL;
66@@ -1851,46 +1854,46 @@ int main(int argc, char **argv)
67
68 /* display requested info */
69 if (stats || all)
70- print_stats(stdout, policydb);
71+ rc = print_stats(stdout, policydb);
72 if (classes || all)
73- print_classes(stdout, class_name, expand, policydb);
74+ rc = print_classes(stdout, class_name, expand, policydb);
75 if (types || all)
76- print_types(stdout, type_name, expand, policydb);
77+ rc = print_types(stdout, type_name, expand, policydb);
78 if (attribs || all)
79- print_attribs(stdout, attrib_name, expand, policydb);
80+ rc = print_attribs(stdout, attrib_name, expand, policydb);
81 if (roles || all)
82- print_roles(stdout, role_name, expand, policydb);
83+ rc = print_roles(stdout, role_name, expand, policydb);
84 if (users || all)
85- print_users(stdout, user_name, expand, policydb);
86+ rc = print_users(stdout, user_name, expand, policydb);
87 if (bools || all)
88- print_booleans(stdout, bool_name, expand, policydb);
89+ rc = print_booleans(stdout, bool_name, expand, policydb);
90 if (sens || all)
91- print_sens(stdout, sens_name, expand, policydb);
92+ rc = print_sens(stdout, sens_name, expand, policydb);
93 if (cats || all)
94- print_cats(stdout, cat_name, expand, policydb);
95+ rc = print_cats(stdout, cat_name, expand, policydb);
96 if (fsuse || all)
97- print_fsuse(stdout, fsuse_type, policydb);
98+ rc = print_fsuse(stdout, fsuse_type, policydb);
99 if (genfs || all)
100- print_genfscon(stdout, genfs_type, policydb);
101+ rc = print_genfscon(stdout, genfs_type, policydb);
102 if (netif || all)
103- print_netifcon(stdout, netif_name, policydb);
104+ rc = print_netifcon(stdout, netif_name, policydb);
105 if (node || all)
106- print_nodecon(stdout, node_addr, policydb);
107+ rc = print_nodecon(stdout, node_addr, policydb);
108 if (port || all)
109- print_portcon(stdout, port_num, protocol, policydb);
110+ rc = print_portcon(stdout, port_num, protocol, policydb);
111 if (isids || all)
112- print_isids(stdout, isid_name, expand, policydb);
113+ rc = print_isids(stdout, isid_name, expand, policydb);
114 if (permissives || all)
115- print_permissives(stdout, permissive_name, expand, policydb);
116+ rc = print_permissives(stdout, permissive_name, expand, policydb);
117 if (polcaps || all)
118- print_polcaps(stdout, polcap_name, expand, policydb);
119+ rc = print_polcaps(stdout, polcap_name, expand, policydb);
120 if (constrain || all)
121- print_constraints(stdout, expand, policydb, linebreaks);
122+ rc = print_constraints(stdout, expand, policydb, linebreaks);
123
124 apol_policy_destroy(&policydb);
125 apol_policy_path_destroy(&pol_path);
126 free(policy_file);
127- exit(0);
128+ exit(rc);
129 }
130
131 /**
132--
1331.7.5.4
134
diff --git a/recipes-security/setools/setools/setools.pam b/recipes-security/setools/setools/setools.pam
new file mode 100644
index 0000000..c7d67e3
--- /dev/null
+++ b/recipes-security/setools/setools/setools.pam
@@ -0,0 +1,4 @@
1#%PAM-1.0
2auth include config-util
3account include config-util
4session include config-util
diff --git a/recipes-security/setools/setools_3.3.7.bb b/recipes-security/setools/setools_3.3.7.bb
new file mode 100644
index 0000000..49cdd88
--- /dev/null
+++ b/recipes-security/setools/setools_3.3.7.bb
@@ -0,0 +1,57 @@
1SUMMARY = "Policy analysis tools for SELinux"
2DESCRIPTION = "\
3SETools is a collection of graphical tools, command-line tools, and \
4libraries designed to facilitate SELinux policy analysis. \
5\n\
6This meta-package depends upon the main packages necessary to run \
7SETools."
8SECTION = "base"
9LICENSE = "GPLv2 & LGPLv2.1"
10PR = "r0"
11
12SRC_URI = "http://oss.tresys.com/projects/setools/chrome/site/dists/setools-${PV}/setools-${PV}.tar.bz2;"
13SRC_URI[md5sum] = "0377d7a06028825434cd7b41a80865a5"
14SRC_URI[sha256sum] = "2bfa0918746bdcc910b16b26a51109a4ffd07404c306141ada584cb36e3c895a"
15
16SRC_URI += "file://setools-Add-seinfo-and-sesearch-python-bindings.patch"
17SRC_URI += "file://setools-seinfo-should-exit-with-correct-errno.patch"
18SRC_URI += "file://setools-Fix-man-pages-and-getoptions.patch"
19SRC_URI += "file://setools-Fix-sepol-calls-to-work-with-latest-libsepol.patch"
20SRC_URI += "file://setools-Changes-to-support-named-file_trans-rules.patch"
21SRC_URI += "file://setools-Remove-unused-variables.patch"
22SRC_URI += "file://setools-Fix-output-to-match-policy-lines.patch"
23
24SRC_URI += "file://setools-Don-t-check-selinux-policies-if-disabled.patch"
25SRC_URI += "file://setools-configure-ac.patch"
26SRC_URI += "file://setools-cross-ar.patch"
27
28SRC_URI += "file://setools-Fix-test-bug-for-unary-operator.patch"
29SRC_URI += "file://setools-Fix-python-setools-Makefile.am-for-cross.patch"
30SRC_URI += "file://setools-Don-t-build-python-bindings-if-disabled.patch"
31
32LIC_FILES_CHKSUM = "file://${S}/COPYING;md5=26035c503c68ae1098177934ac0cc795 \
33 file://${S}/COPYING.GPL;md5=751419260aa954499f7abaabaa882bbe \
34 file://${S}/COPYING.LGPL;md5=fbc093901857fcd118f065f900982c24"
35
36DEPENDS += "python python-native libsepol libselinux refpolicy"
37
38inherit autotools
39
40do_configure() {
41 autoreconf --force --install
42 export ac_cv_policydb_version_max=26
43 export PYTHON=python
44 export PYLIBVER='python${PYTHON_BASEVERSION}'
45 export PYTHON_CPPFLAGS="-I${STAGING_INCDIR}/${PYLIBVER}"
46 export PYTHON_LDFLAGS="-L${STAGING_LIBDIR}/${PYLIBVER} -l${PYLIBVER}"
47 export PYTHON_SITE_PKG="${libdir}/${PYLIBVER}/site-packages"
48 oe_runconf --disable-bwidget-check --disable-selinux-check \
49 --disable-swig-python --disable-swig-java --disable-swig-tcl \
50 --disable-profiling --disable-gui --with-tk=no --with-tcl=no \
51 --with-sepol-devel=${STAGING_LIBDIR}/.. \
52 --with-selinux-devel=${STAGING_LIBDIR}/..
53}
54
55do_install_append() {
56 rm -f ${D}/${libdir}/*.a
57}