[setools/f14/master] * Tue Aug 3 2010 Dan Walsh <dwalsh at redhat.com> 3.3.6-5 - Add port support to setools python

Daniel J Walsh dwalsh at fedoraproject.org
Tue Aug 3 20:58:47 UTC 2010


commit fb8049872477ad3828e1170bb89408ba4d24a5c1
Author: Dan Walsh <dwalsh at redhat.com>
Date:   Tue Aug 3 16:58:37 2010 -0400

    * Tue Aug 3 2010 Dan Walsh <dwalsh at redhat.com> 3.3.6-5
    - Add port support to setools python

 setools-python.patch |   40 +++++++++++++++++++++++++---------------
 1 files changed, 25 insertions(+), 15 deletions(-)
---
diff --git a/setools-python.patch b/setools-python.patch
index bcbcb11..ceca4af 100644
--- a/setools-python.patch
+++ b/setools-python.patch
@@ -1463,8 +1463,8 @@ diff -up setools-3.3.7/python/setools/Makefile.in.python setools-3.3.7/python/se
 +.NOEXPORT:
 diff -up setools-3.3.7/python/setools/seinfo.c.python setools-3.3.7/python/setools/seinfo.c
 --- setools-3.3.7/python/setools/seinfo.c.python	2010-07-30 15:02:10.000000000 -0400
-+++ setools-3.3.7/python/setools/seinfo.c	2010-08-03 16:01:06.000000000 -0400
-@@ -0,0 +1,744 @@
++++ setools-3.3.7/python/setools/seinfo.c	2010-08-03 16:49:15.000000000 -0400
+@@ -0,0 +1,754 @@
 +/**
 + *  @file
 + *  Command line tool to search TE rules.
@@ -1536,7 +1536,7 @@ diff -up setools-3.3.7/python/setools/seinfo.c.python setools-3.3.7/python/setoo
 +{
 +	int retval = -1;
 +	PyObject *dict = PyDict_New(); 
-+	const qpol_type_t *attr_datum = NULL;
++	const qpol_type_t *atotr_datum = NULL;
 +	qpol_iterator_t *iter = NULL;
 +	const char *attr_name = NULL, *type_name = NULL;
 +	qpol_policy_t *q = apol_policy_get_qpol(policydb);
@@ -1950,11 +1950,14 @@ diff -up setools-3.3.7/python/setools/seinfo.c.python setools-3.3.7/python/setoo
 +	const qpol_portcon_t *portcon = NULL;
 +	qpol_iterator_t *iter = NULL;
 +	uint16_t low_port, high_port;
-+	uint8_t ocon_proto, proto = 0;
++	uint8_t ocon_proto;
 +	qpol_policy_t *q = apol_policy_get_qpol(policydb);
 +	const qpol_context_t *ctxt = NULL;
 +	const char *proto_str;
 +	PyObject *dict;
++	const char *type = NULL;
++	PyObject *obj = NULL;
++	apol_context_t *c = NULL;
 +
 +	if (qpol_policy_get_portcon_iter(q, &iter))
 +		goto cleanup;
@@ -1977,7 +1980,7 @@ diff -up setools-3.3.7/python/setools/seinfo.c.python setools-3.3.7/python/setoo
 +		    (ocon_proto != IPPROTO_UDP)) 
 +			goto cleanup;
 +
-+		if (qpol_portcon_get_context(q, portcon,&ctxt)) {
++		if (qpol_portcon_get_context(q, portcon, &ctxt)) {
 +			PyErr_SetString(PyExc_RuntimeError, "Could not get for port context.");
 +			goto cleanup;
 +		}
@@ -1987,8 +1990,22 @@ diff -up setools-3.3.7/python/setools/seinfo.c.python setools-3.3.7/python/setoo
 +			goto cleanup;
 +		}
 +
++		if ((c = apol_context_create_from_qpol_context(policydb, ctxt)) == NULL) {
++			goto cleanup;
++		}
++		
++		if((type = apol_context_get_type(c)) == NULL) {
++			apol_context_destroy(&c);
++			goto cleanup;
++		}
++			
 +		dict = PyDict_New(); 
-+		PyObject *obj = PyString_FromString(proto_str);
++		obj = PyString_FromString(type);
++		PyDict_SetItemString(dict, "type", obj);
++		Py_DECREF(obj);
++		apol_context_destroy(&c);
++
++		obj = PyString_FromString(proto_str);
 +		PyDict_SetItemString(dict, "protocol", obj);
 +		Py_DECREF(obj);
 +
@@ -2000,20 +2017,13 @@ diff -up setools-3.3.7/python/setools/seinfo.c.python setools-3.3.7/python/setoo
 +		PyDict_SetItemString(dict, "low", obj);
 +		Py_DECREF(obj);
 +
-+		char *tmp = apol_qpol_context_render(policydb, ctxt);
-+		obj = PyString_FromString(tmp);
-+		free(tmp);
-+		PyDict_SetItemString(dict, "type", obj);
-+		Py_DECREF(obj);
-+
 +		PyList_Append(list, dict);
-+		Py_DECREF(obj);
++		Py_DECREF(dict);
 +	}
-+	qpol_iterator_destroy(&iter);
-+
 +	retval = 0;
 +      cleanup:
 +	qpol_iterator_destroy(&iter);
++
 +	if (retval) {
 +		Py_DECREF(list);
 +		PyErr_SetString(PyExc_RuntimeError,strerror(errno));


More information about the scm-commits mailing list