From: <ssm...@us...> - 2007-02-21 17:02:26
|
Revision: 2243 http://svn.sourceforge.net/selinux/?rev=2243&view=rev Author: ssmalley Date: 2007-02-21 09:02:11 -0800 (Wed, 21 Feb 2007) Log Message: ----------- Author: Daniel J Walsh Email: dw...@re... Subject: libselinux patch Date: Tue, 20 Feb 2007 09:31:00 -0500 This patch initializes all swig parameters to prevent possible crashes in python. Modified Paths: -------------- trunk/libselinux/src/selinux.py trunk/libselinux/src/selinuxswig.i trunk/libselinux/src/selinuxswig_wrap.c Modified: trunk/libselinux/src/selinux.py =================================================================== --- trunk/libselinux/src/selinux.py 2007-02-20 14:06:53 UTC (rev 2242) +++ trunk/libselinux/src/selinux.py 2007-02-21 17:02:11 UTC (rev 2243) @@ -1,10 +1,16 @@ -# This file was created automatically by SWIG 1.3.29. +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 1.3.31 +# # Don't modify this file, modify the SWIG interface instead. # This file is compatible with both classic and new-style classes. import _selinux import new new_instancemethod = new.instancemethod +try: + _swig_property = property +except NameError: + pass # Python < 2.2 doesn't have 'property'. def _swig_setattr_nondynamic(self,class_type,name,value,static=1): if (name == "thisown"): return self.this.own(value) if (name == "this"): Modified: trunk/libselinux/src/selinuxswig.i =================================================================== --- trunk/libselinux/src/selinuxswig.i 2007-02-20 14:06:53 UTC (rev 2242) +++ trunk/libselinux/src/selinuxswig.i 2007-02-21 17:02:11 UTC (rev 2243) @@ -28,7 +28,7 @@ %typemap(in, numinputs=0) security_context_t *(security_context_t temp=NULL) { $1 = &temp; } -%typemap(argout) security_context_t * (char *temp) { +%typemap(argout) security_context_t * (char *temp=NULL) { if (*$1) temp = *$1; else @@ -126,7 +126,7 @@ extern int selinux_raw_to_trans_context(char *raw, security_context_t *transp); -%typemap(in, numinputs=0) char **(char *temp) { +%typemap(in, numinputs=0) char **(char *temp=NULL) { $1 = &temp; } Modified: trunk/libselinux/src/selinuxswig_wrap.c =================================================================== --- trunk/libselinux/src/selinuxswig_wrap.c 2007-02-20 14:06:53 UTC (rev 2242) +++ trunk/libselinux/src/selinuxswig_wrap.c 2007-02-21 17:02:11 UTC (rev 2243) @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.29 + * Version 1.3.31 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -103,7 +103,7 @@ #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE #endif @@ -120,7 +120,7 @@ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "2" +#define SWIG_RUNTIME_VERSION "3" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE @@ -697,8 +697,6 @@ -/* Python.h has to appear first */ -#include <Python.h> /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 @@ -779,6 +777,14 @@ } #endif +/* Py_ssize_t for old Pythons */ +/* This code is as recommended by: */ +/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +# define PY_SSIZE_T_MAX INT_MAX +# define PY_SSIZE_T_MIN INT_MIN +#endif /* ----------------------------------------------------------------------------- * error manipulation @@ -1172,7 +1178,7 @@ SWIGRUNTIMEINLINE PyObject * _SWIG_Py_None(void) { - PyObject *none = Py_BuildValue(""); + PyObject *none = Py_BuildValue((char*)""); Py_DECREF(none); return none; } @@ -2031,7 +2037,7 @@ void *vptr = 0; /* here we get the method pointer for callbacks */ - char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) { desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; @@ -2152,7 +2158,7 @@ return; } #endif - dict = PyObject_GetAttrString(inst, "__dict__"); + dict = PyObject_GetAttrString(inst, (char*)"__dict__"); PyDict_SetItem(dict, SWIG_This(), swig_this); Py_DECREF(dict); } @@ -2293,7 +2299,7 @@ /* The python cached type query */ SWIGRUNTIME PyObject * -SWIG_Python_TypeCache() { +SWIG_Python_TypeCache(void) { static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); return cache; } @@ -2459,7 +2465,7 @@ #if (PY_VERSION_HEX <= 0x02000000) # if !defined(SWIG_PYTHON_CLASSIC) -# error "This python version requires to use swig with the '-classic' option" +# error "This python version requires swig to be run with the '-classic' option" # endif #endif @@ -2470,7 +2476,8 @@ #define SWIG_name "_selinux" -#define SWIGVERSION 0x010329 +#define SWIGVERSION 0x010331 +#define SWIG_VERSION SWIGVERSION #define SWIG_as_voidptr(a) (void *)((const void *)(a)) @@ -2638,7 +2645,7 @@ SWIGINTERN swig_type_info* -SWIG_pchar_descriptor() +SWIG_pchar_descriptor(void) { static int init = 0; static swig_type_info* info = 0; @@ -2654,7 +2661,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { if (PyString_Check(obj)) { - char *cstr; int len; + char *cstr; Py_ssize_t len; PyString_AsStringAndSize(obj, &cstr, &len); if (cptr) { if (alloc) { @@ -2832,7 +2839,7 @@ security_context_t *arg1 = (security_context_t *) 0 ; int result; security_context_t temp1 = NULL ; - char *temp10 ; + char *temp10 = NULL ; { arg1 = &temp1; @@ -2879,7 +2886,7 @@ int val1 ; int ecode1 = 0 ; security_context_t temp2 = NULL ; - char *temp20 ; + char *temp20 = NULL ; PyObject * obj0 = 0 ; { @@ -2911,7 +2918,7 @@ security_context_t *arg1 = (security_context_t *) 0 ; int result; security_context_t temp1 = NULL ; - char *temp10 ; + char *temp10 = NULL ; { arg1 = &temp1; @@ -2937,7 +2944,7 @@ security_context_t *arg1 = (security_context_t *) 0 ; int result; security_context_t temp1 = NULL ; - char *temp10 ; + char *temp10 = NULL ; { arg1 = &temp1; @@ -2981,7 +2988,7 @@ security_context_t *arg1 = (security_context_t *) 0 ; int result; security_context_t temp1 = NULL ; - char *temp10 ; + char *temp10 = NULL ; { arg1 = &temp1; @@ -3025,7 +3032,7 @@ security_context_t *arg1 = (security_context_t *) 0 ; int result; security_context_t temp1 = NULL ; - char *temp10 ; + char *temp10 = NULL ; { arg1 = &temp1; @@ -3069,7 +3076,7 @@ security_context_t *arg1 = (security_context_t *) 0 ; int result; security_context_t temp1 = NULL ; - char *temp10 ; + char *temp10 = NULL ; { arg1 = &temp1; @@ -3117,7 +3124,7 @@ char *buf1 = 0 ; int alloc1 = 0 ; security_context_t temp2 = NULL ; - char *temp20 ; + char *temp20 = NULL ; PyObject * obj0 = 0 ; { @@ -3128,7 +3135,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "getfilecon" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); result = (int)getfilecon((char const *)arg1,arg2); resultobj = SWIG_From_int((int)(result)); { @@ -3155,7 +3162,7 @@ char *buf1 = 0 ; int alloc1 = 0 ; security_context_t temp2 = NULL ; - char *temp20 ; + char *temp20 = NULL ; PyObject * obj0 = 0 ; { @@ -3166,7 +3173,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "lgetfilecon" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); result = (int)lgetfilecon((char const *)arg1,arg2); resultobj = SWIG_From_int((int)(result)); { @@ -3192,7 +3199,7 @@ int val1 ; int ecode1 = 0 ; security_context_t temp2 = NULL ; - char *temp20 ; + char *temp20 = NULL ; PyObject * obj0 = 0 ; { @@ -3235,7 +3242,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "setfilecon" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); { arg2 = (security_context_t)PyString_AsString(obj1); } @@ -3265,7 +3272,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "lsetfilecon" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); { arg2 = (security_context_t)PyString_AsString(obj1); } @@ -3314,7 +3321,7 @@ int val1 ; int ecode1 = 0 ; security_context_t temp2 = NULL ; - char *temp20 ; + char *temp20 = NULL ; PyObject * obj0 = 0 ; { @@ -3440,7 +3447,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "security_load_booleans" "', argument " "1"" of type '" "char *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); result = (int)security_load_booleans(arg1); resultobj = SWIG_From_int((int)(result)); if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); @@ -3475,7 +3482,7 @@ security_context_t *arg2 = (security_context_t *) 0 ; int result; security_context_t temp2 = NULL ; - char *temp20 ; + char *temp20 = NULL ; PyObject * obj0 = 0 ; { @@ -3594,7 +3601,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "security_get_boolean_pending" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); result = (int)security_get_boolean_pending((char const *)arg1); resultobj = SWIG_From_int((int)(result)); if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); @@ -3619,7 +3626,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "security_get_boolean_active" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); result = (int)security_get_boolean_active((char const *)arg1); resultobj = SWIG_From_int((int)(result)); if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); @@ -3648,7 +3655,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "security_set_boolean" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "security_set_boolean" "', argument " "2"" of type '" "int""'"); @@ -3712,7 +3719,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "matchpathcon_init" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); result = (int)matchpathcon_init((char const *)arg1); resultobj = SWIG_From_int((int)(result)); if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); @@ -3735,7 +3742,7 @@ unsigned int val2 ; int ecode2 = 0 ; security_context_t temp3 = NULL ; - char *temp30 ; + char *temp30 = NULL ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; @@ -3747,7 +3754,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "matchpathcon" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "matchpathcon" "', argument " "2"" of type '" "mode_t""'"); @@ -3779,7 +3786,7 @@ char *buf1 = 0 ; int alloc1 = 0 ; security_context_t temp2 = NULL ; - char *temp20 ; + char *temp20 = NULL ; PyObject * obj0 = 0 ; { @@ -3790,7 +3797,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "matchmediacon" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); result = (int)matchmediacon((char const *)arg1,arg2); resultobj = SWIG_From_int((int)(result)); { @@ -3837,7 +3844,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_policy_root")) SWIG_fail; result = (char *)selinux_policy_root(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -3850,7 +3857,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_binary_policy_path")) SWIG_fail; result = (char *)selinux_binary_policy_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -3863,7 +3870,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_failsafe_context_path")) SWIG_fail; result = (char *)selinux_failsafe_context_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -3876,7 +3883,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_removable_context_path")) SWIG_fail; result = (char *)selinux_removable_context_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -3889,7 +3896,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_default_context_path")) SWIG_fail; result = (char *)selinux_default_context_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -3902,7 +3909,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_user_contexts_path")) SWIG_fail; result = (char *)selinux_user_contexts_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -3915,7 +3922,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_file_context_path")) SWIG_fail; result = (char *)selinux_file_context_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -3928,7 +3935,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_file_context_homedir_path")) SWIG_fail; result = (char *)selinux_file_context_homedir_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -3941,7 +3948,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_file_context_local_path")) SWIG_fail; result = (char *)selinux_file_context_local_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -3954,7 +3961,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_homedir_context_path")) SWIG_fail; result = (char *)selinux_homedir_context_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -3967,7 +3974,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_media_context_path")) SWIG_fail; result = (char *)selinux_media_context_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -3980,7 +3987,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_contexts_path")) SWIG_fail; result = (char *)selinux_contexts_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -3993,7 +4000,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_booleans_path")) SWIG_fail; result = (char *)selinux_booleans_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -4006,7 +4013,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_customizable_types_path")) SWIG_fail; result = (char *)selinux_customizable_types_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -4019,7 +4026,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_users_path")) SWIG_fail; result = (char *)selinux_users_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -4032,7 +4039,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_usersconf_path")) SWIG_fail; result = (char *)selinux_usersconf_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -4045,7 +4052,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_translations_path")) SWIG_fail; result = (char *)selinux_translations_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -4058,7 +4065,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_netfilter_context_path")) SWIG_fail; result = (char *)selinux_netfilter_context_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -4071,7 +4078,7 @@ if (!PyArg_ParseTuple(args,(char *)":selinux_path")) SWIG_fail; result = (char *)selinux_path(); - resultobj = SWIG_FromCharPtr(result); + resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; @@ -4165,7 +4172,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rpm_execcon" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = (char *)(buf2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_p_char, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "rpm_execcon" "', argument " "3"" of type '" "char *const []""'"); @@ -4213,7 +4220,7 @@ char *buf1 = 0 ; int alloc1 = 0 ; security_context_t temp2 = NULL ; - char *temp20 ; + char *temp20 = NULL ; PyObject * obj0 = 0 ; { @@ -4224,7 +4231,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "selinux_trans_to_raw_context" "', argument " "1"" of type '" "char *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); result = (int)selinux_trans_to_raw_context(arg1,arg2); resultobj = SWIG_From_int((int)(result)); { @@ -4251,7 +4258,7 @@ char *buf1 = 0 ; int alloc1 = 0 ; security_context_t temp2 = NULL ; - char *temp20 ; + char *temp20 = NULL ; PyObject * obj0 = 0 ; { @@ -4262,7 +4269,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "selinux_raw_to_trans_context" "', argument " "1"" of type '" "char *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); result = (int)selinux_raw_to_trans_context(arg1,arg2); resultobj = SWIG_From_int((int)(result)); { @@ -4284,7 +4291,7 @@ PyObject *resultobj = 0; char **arg1 = (char **) 0 ; int result; - char *temp1 ; + char *temp1 = NULL ; { arg1 = &temp1; @@ -4310,8 +4317,8 @@ int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; - char *temp2 ; - char *temp3 ; + char *temp2 = NULL ; + char *temp3 = NULL ; PyObject * obj0 = 0 ; { @@ -4325,7 +4332,7 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "getseuserbyname" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = (char *)(buf1); result = (int)getseuserbyname((char const *)arg1,arg2,arg3); resultobj = SWIG_From_int((int)(result)); { @@ -4479,7 +4486,7 @@ * structures together. * * The generated swig_type_info structures are assigned staticly to an initial - * array. We just loop though that array, and handle each type individually. + * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the * cast linked list. The cast data is initially stored in something like a @@ -4517,30 +4524,47 @@ #define SWIGRUNTIME_DEBUG #endif + SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; - swig_module_info *module_head; - static int init_run = 0; + swig_module_info *module_head, *iter; + int found; clientdata = clientdata; - if (init_run) return; - init_run = 1; + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + } - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; - /* Try and load any already created modules */ module_head = SWIG_GetModule(clientdata); - if (module_head) { + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + module_head = &swig_module; + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + found=0; + iter=module_head; + do { + if (iter==&swig_module) { + found=1; + break; + } + iter=iter->next; + } while (iter!= module_head); + + /* if the is found in the list, then all is done and we may leave */ + if (found) return; + /* otherwise we must add out module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; - } else { - /* This is the first module loaded */ - swig_module.next = &swig_module; - SWIG_SetModule(clientdata, &swig_module); } /* Now work on filling in swig_module.types */ @@ -4853,7 +4877,7 @@ } SWIGINTERN PyObject * - SWIG_globals() { + SWIG_globals(void) { static PyObject *_SWIG_globals = 0; if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); return _SWIG_globals; @@ -4898,11 +4922,11 @@ swig_type_info **types_initial) { size_t i; for (i = 0; methods[i].ml_name; ++i) { - char *c = methods[i].ml_doc; + const char *c = methods[i].ml_doc; if (c && (c = strstr(c, "swig_ptr: "))) { int j; swig_const_info *ci = 0; - char *name = c + 10; + const char *name = c + 10; for (j = 0; const_table[j].type; ++j) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2007-02-23 18:24:17
|
Revision: 2268 http://svn.sourceforge.net/selinux/?rev=2268&view=rev Author: ssmalley Date: 2007-02-23 10:24:15 -0800 (Fri, 23 Feb 2007) Log Message: ----------- Author: Stephen Smalley Email: sd...@ty... Subject: Remove init_context_translations() from libselinux Date: Fri, 23 Feb 2007 07:43:49 -0500 On Thu, 2007-02-22 at 10:53 -0600, Darrel Goeddel wrote: > Daniel J Walsh wrote: > > Stephen Smalley wrote: > >> I think we've talked about this before, but never followed through. > >> Is there any reason to retain the init_context_translations() function > >> in libselinux, which sends a SETRANS_INIT message to mcstransd, gets a > >> response, and discards it? Can we drop it and the call to it from the > >> library constructor/initializer? > >> > >> > > Ok with me. > > Removal looks OK to me. It used to be that a failure would cause > translations to be disabled, but it is now vestigial. On second look, we need to retain the function to set mls_enabled for later use, but we can drop the part that communicates with mcstransd. Patch below. Signed-off-by: Stephen Smalley <sd...@ty...> Modified Paths: -------------- trunk/libselinux/src/setrans_client.c trunk/libselinux/src/setrans_internal.h Modified: trunk/libselinux/src/setrans_client.c =================================================================== --- trunk/libselinux/src/setrans_client.c 2007-02-22 16:11:13 UTC (rev 2267) +++ trunk/libselinux/src/setrans_client.c 2007-02-23 18:24:15 UTC (rev 2268) @@ -213,29 +213,8 @@ hidden int init_context_translations(void) { - int ret, fd; - int32_t ret_val; - char *out = NULL; - mls_enabled = is_selinux_mls_enabled(); - if (!mls_enabled) - return 0; - - fd = setransd_open(); - if (fd < 0) - return fd; - - ret = send_request(fd, SETRANS_INIT, NULL, NULL); - if (ret) - goto out; - - ret = receive_response(fd, SETRANS_INIT, &out, &ret_val); - free(out); - if (!ret) - ret = ret_val; - out: - close(fd); - return ret; + return 0; } int selinux_trans_to_raw_context(security_context_t trans, Modified: trunk/libselinux/src/setrans_internal.h =================================================================== --- trunk/libselinux/src/setrans_internal.h 2007-02-22 16:11:13 UTC (rev 2267) +++ trunk/libselinux/src/setrans_internal.h 2007-02-23 18:24:15 UTC (rev 2268) @@ -2,7 +2,6 @@ #define SETRANS_UNIX_SOCKET "/var/run/setrans/.setrans-unix" -#define SETRANS_INIT 1 #define RAW_TO_TRANS_CONTEXT 2 #define TRANS_TO_RAW_CONTEXT 3 #define MAX_DATA_BUF 8192 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2007-02-27 15:06:14
|
Revision: 2273 http://svn.sourceforge.net/selinux/?rev=2273&view=rev Author: ssmalley Date: 2007-02-27 06:57:14 -0800 (Tue, 27 Feb 2007) Log Message: ----------- Author: Steve G Email: lin...@ya... Subject: libselinux patch Date: Mon, 26 Feb 2007 08:40:43 -0800 (PST) OK, I think the attached patch does _everything _ we discussed. It: - removes 8 syscalls for the normal path - ensures /selinux is trully an selinuxfs - drops back to detecting the old way when /selinux is missing - changes the old way in is_enabled to use fopen & getline for glibc internal retries - adds retry for EINTR in mls_enabled - keeps SELINUX_MAGIC private Signed-off-by: Steve Grubb <lin...@ya...> [amended by:] Not sending this to mail list as I've sent so many variations of this. I noticed that I forgot the call to __fsetlocking before the getline() calls. So, the attached patch is updated to have that and should be otherwise identical. Modified Paths: -------------- trunk/libselinux/src/enabled.c trunk/libselinux/src/init.c trunk/libselinux/src/load_policy.c trunk/libselinux/src/policy.h Modified: trunk/libselinux/src/enabled.c =================================================================== --- trunk/libselinux/src/enabled.c 2007-02-27 14:52:46 UTC (rev 2272) +++ trunk/libselinux/src/enabled.c 2007-02-27 14:57:14 UTC (rev 2273) @@ -6,50 +6,63 @@ #include <errno.h> #include <limits.h> #include <stdio.h> +#include <stdio_ext.h> #include "policy.h" int is_selinux_enabled(void) { - char *buf; - size_t size; - int fd; - ssize_t ret; + char *buf=NULL; + FILE *fp; + ssize_t num; + size_t len; int enabled = 0; security_context_t con; - fd = open("/proc/filesystems", O_RDONLY); - if (fd < 0) - return -1; + /* init_selinuxmnt() gets called before this function. We + * will assume that if a selinux file system is mounted, then + * selinux is enabled. */ + if (selinux_mnt) { - size = selinux_page_size; - buf = malloc(size); - if (!buf) { - enabled = -1; - goto out; - } + /* Since a file system is mounted, we consider selinux + * enabled. If getcon_raw fails, selinux is still enabled. + * We only consider it disabled if no policy is loaded. */ + enabled = 1; + if (getcon_raw(&con) == 0) { + if (!strcmp(con, "kernel")) + enabled = 0; + freecon(con); + } + return enabled; + } - memset(buf, 0, size); + /* Drop back to detecting it the long way. */ + fp = fopen("/proc/filesystems", "r"); + if (!fp) + return -1; - ret = read(fd, buf, size - 1); - if (ret < 0) { - enabled = -1; - goto out2; + __fsetlocking(fp, FSETLOCKING_BYCALLER); + while ((num = getline(&buf, &len, fp)) != -1) { + if (strstr(buf, "selinuxfs")) { + enabled = 1; + break; + } } - if (!strstr(buf, "selinuxfs")) - goto out2; + if (num < 0) + goto out; - enabled = 1; - + /* Since an selinux file system is available, we consider + * selinux enabled. If getcon_raw fails, selinux is still + * enabled. We only consider it disabled if no policy is loaded. */ if (getcon_raw(&con) == 0) { if (!strcmp(con, "kernel")) enabled = 0; freecon(con); } - out2: + + out: free(buf); - out: - close(fd); + fclose(fp); return enabled; } @@ -75,7 +88,9 @@ memset(buf, 0, sizeof buf); - ret = read(fd, buf, sizeof buf - 1); + do { + ret = read(fd, buf, sizeof buf - 1); + } while (ret < 0 && errno == EINTR); close(fd); if (ret < 0) return enabled; Modified: trunk/libselinux/src/init.c =================================================================== --- trunk/libselinux/src/init.c 2007-02-27 14:52:46 UTC (rev 2272) +++ trunk/libselinux/src/init.c 2007-02-27 14:57:14 UTC (rev 2273) @@ -5,8 +5,10 @@ #include <errno.h> #include <ctype.h> #include <stdio.h> +#include <stdio_ext.h> #include <dlfcn.h> -#include <unistd.h> +#include <sys/vfs.h> +#include <stdint.h> #include "dso.h" #include "policy.h" @@ -18,51 +20,58 @@ static void init_selinuxmnt(void) { - char *buf, *bufp, *p; - size_t size; + char *buf=NULL, *p; FILE *fp; + struct statfs sfbuf; + int rc; + size_t len; + ssize_t num; if (selinux_mnt) return; + /* We check to see if the preferred mount point for selinux file + * system has a selinuxfs. */ + do { + rc = statfs(SELINUXMNT, &sfbuf); + } while (rc < 0 && errno == EINTR); + if (rc == 0) { + if ((uint32_t)sfbuf.f_type == (uint32_t)SELINUX_MAGIC) { + selinux_mnt = strdup(SELINUXMNT); + return; + } + } + + /* At this point, the usual spot doesn't have an selinuxfs so + * we look around for it */ fp = fopen("/proc/mounts", "r"); if (!fp) return; - size = selinux_page_size; - - buf = malloc(size); - if (!buf) - goto out; - - memset(buf, 0, size); - - while ((bufp = fgets_unlocked(buf, size, fp))) { + __fsetlocking(fp, FSETLOCKING_BYCALLER); + while ((num = getline(&buf, &len, fp)) != -1) { char *tmp; p = strchr(buf, ' '); if (!p) - goto out2; + goto out; p++; tmp = strchr(p, ' '); if (!tmp) - goto out2; + goto out; if (!strncmp(tmp + 1, "selinuxfs ", 10)) { *tmp = '\0'; break; } } - if (!bufp) - goto out2; + /* If we found something, dup it */ + if (num > 0) + selinux_mnt = strdup(p); - selinux_mnt = strdup(p); - - out2: + out: free(buf); - out: fclose(fp); return; - } static void fini_selinuxmnt(void) Modified: trunk/libselinux/src/load_policy.c =================================================================== --- trunk/libselinux/src/load_policy.c 2007-02-27 14:52:46 UTC (rev 2272) +++ trunk/libselinux/src/load_policy.c 2007-02-27 14:57:14 UTC (rev 2273) @@ -165,7 +165,6 @@ * We only need the hardcoded definition for the initial mount * required for the initial policy load. */ -#define SELINUXMNT "/selinux/" int selinux_init_load_policy(int *enforce) { int rc = 0, orig_enforce = 0, seconfig = -2, secmdline = -1; Modified: trunk/libselinux/src/policy.h =================================================================== --- trunk/libselinux/src/policy.h 2007-02-27 14:52:46 UTC (rev 2272) +++ trunk/libselinux/src/policy.h 2007-02-27 14:57:14 UTC (rev 2273) @@ -9,6 +9,12 @@ /* Initial length guess for getting contexts. */ #define INITCONTEXTLEN 255 +/* selinuxfs magic number */ +#define SELINUX_MAGIC 0xf97cff8c + +/* Preferred selinux mount location */ +#define SELINUXMNT "/selinux" + /* selinuxfs mount point */ extern char *selinux_mnt; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2007-03-12 15:33:14
|
Revision: 2287 http://svn.sourceforge.net/selinux/?rev=2287&view=rev Author: ssmalley Date: 2007-03-12 08:33:08 -0700 (Mon, 12 Mar 2007) Log Message: ----------- Author: Steve G Email: lin...@ya... Subject: Dropping compat support for /etc/security policy file paths Date: Thu, 8 Mar 2007 05:31:19 -0800 (PST) >> >Are any active distributions still using the old /etc/security/ location >> >and layout for SELinux policy files? If not, we could drop the compat >> >file path support from libselinux on the trunk. >> >> Here's a patch dropping support. > >+#define SECURITYCONFIG "/etc/sysconfig/selinux" > >I think we can drop this altogether, along with the use of it Sure. New patch attached. -Steve Modified Paths: -------------- trunk/libselinux/src/selinux_config.c Removed Paths: ------------- trunk/libselinux/src/compat_file_path.h Deleted: trunk/libselinux/src/compat_file_path.h =================================================================== --- trunk/libselinux/src/compat_file_path.h 2007-03-12 15:25:34 UTC (rev 2286) +++ trunk/libselinux/src/compat_file_path.h 2007-03-12 15:33:08 UTC (rev 2287) @@ -1,12 +0,0 @@ -/* Compatibility file name suffixes. */ -S_(BINPOLICY, SECURITYDIR "/selinux/policy") - S_(CONTEXTS_DIR, SECURITYDIR) - S_(FILE_CONTEXTS, SECURITYDIR "/selinux/file_contexts") - S_(HOMEDIR_CONTEXTS, SECURITYDIR "/homedir_template") - S_(DEFAULT_CONTEXTS, SECURITYDIR "/default_contexts") - S_(USER_CONTEXTS, SECURITYDIR "/default_contexts.user/") - S_(FAILSAFE_CONTEXT, SECURITYDIR "/failsafe_context") - S_(DEFAULT_TYPE, SECURITYDIR "/default_type") - S_(BOOLEANS, SECURITYDIR "/booleans") - S_(MEDIA_CONTEXTS, SECURITYDIR "/default_media") - S_(REMOVABLE_CONTEXT, SECURITYDIR "/removable_context") Modified: trunk/libselinux/src/selinux_config.c =================================================================== --- trunk/libselinux/src/selinux_config.c 2007-03-12 15:25:34 UTC (rev 2286) +++ trunk/libselinux/src/selinux_config.c 2007-03-12 15:33:08 UTC (rev 2287) @@ -65,44 +65,16 @@ #undef S_ }; -/* Old layout had fixed locations. */ -#define SECURITYCONFIG "/etc/sysconfig/selinux" -#define SECURITYDIR "/etc/security" -static const union compat_file_path_data { - struct { -#define S_(n, s) char L1(__LINE__)[sizeof(s)]; -#include "compat_file_path.h" -#undef S_ - }; - char str[0]; -} compat_file_path_data = { - { -#define S_(n, s) s, -#include "compat_file_path.h" -#undef S_ - } -}; -static const uint16_t compat_file_path_idx[NEL] = { -#define S_(n, s) [n] = offsetof(union compat_file_path_data, L1(__LINE__)), -#include "compat_file_path.h" -#undef S_ -}; - #undef L1 #undef L2 -static int use_compat_file_path; - int selinux_getenforcemode(int *enforce) { int ret = -1; FILE *cfg = fopen(SELINUXCONFIG, "r"); - char *buf; - int len = sizeof(SELINUXTAG) - 1; - if (!cfg) { - cfg = fopen(SECURITYCONFIG, "r"); - } if (cfg) { + char *buf; + int len = sizeof(SELINUXTAG) - 1; buf = malloc(selinux_page_size); if (!buf) { fclose(cfg); @@ -167,12 +139,6 @@ if (selinux_policyroot) return; - if (access(SELINUXDIR, F_OK) != 0) { - selinux_policyroot = SECURITYDIR; - selinux_rootpath = SECURITYDIR; - use_compat_file_path = 1; - return; - } selinux_rootpath = SELINUXDIR; fp = fopen(SELINUXCONFIG, "r"); @@ -244,7 +210,6 @@ file_path_suffixes_idx[i]) == -1) return; - use_compat_file_path = 0; } static void fini_selinux_policyroot(void) __attribute__ ((destructor)); @@ -252,10 +217,6 @@ static void fini_selinux_policyroot(void) { int i; - if (use_compat_file_path) { - selinux_policyroot = NULL; - return; - } free(selinux_policyroot); selinux_policyroot = NULL; for (i = 0; i < NEL; i++) { @@ -268,10 +229,7 @@ static const char *get_path(int idx) { - if (!use_compat_file_path) - return file_paths[idx]; - - return compat_file_path_data.str + compat_file_path_idx[idx]; + return file_paths[idx]; } const char *selinux_default_type_path() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2007-03-12 16:45:28
|
Revision: 2289 http://svn.sourceforge.net/selinux/?rev=2289&view=rev Author: ssmalley Date: 2007-03-12 09:45:03 -0700 (Mon, 12 Mar 2007) Log Message: ----------- Author: Steve G Email: lin...@ya... Subject: Dropping support for disabling caching of context translations (CACHETRANS=0) Date: Thu, 8 Mar 2007 06:53:23 -0800 (PST) >So, is anyone using CACHETRANS=0? Do we need to retain it going forward >in the trunk? Attaching a patch dropping this config option. -Steve Modified Paths: -------------- trunk/libselinux/src/selinux_config.c trunk/libselinux/src/selinux_internal.h trunk/libselinux/src/setrans_client.c Modified: trunk/libselinux/src/selinux_config.c =================================================================== --- trunk/libselinux/src/selinux_config.c 2007-03-12 15:34:29 UTC (rev 2288) +++ trunk/libselinux/src/selinux_config.c 2007-03-12 16:45:03 UTC (rev 2289) @@ -17,7 +17,6 @@ #define SELINUXTAG "SELINUX=" #define SETLOCALDEFS "SETLOCALDEFS=" #define REQUIRESEUSERS "REQUIRESEUSERS=" -#define CACHETRANSTAG "CACHETRANS=" /* Indices for file paths arrays. */ #define BINPOLICY 0 @@ -174,10 +173,6 @@ sizeof(REQUIRESEUSERS) - 1)) { value = buf_p + sizeof(REQUIRESEUSERS) - 1; intptr = &require_seusers; - } else if (!strncmp(buf_p, CACHETRANSTAG, - sizeof(CACHETRANSTAG) - 1)) { - value = buf_p + sizeof(CACHETRANSTAG) - 1; - intptr = &cache_trans; } else { continue; } Modified: trunk/libselinux/src/selinux_internal.h =================================================================== --- trunk/libselinux/src/selinux_internal.h 2007-03-12 15:34:29 UTC (rev 2288) +++ trunk/libselinux/src/selinux_internal.h 2007-03-12 16:45:03 UTC (rev 2289) @@ -80,4 +80,3 @@ extern int load_setlocaldefs hidden; extern int require_seusers hidden; extern int selinux_page_size hidden; -extern int cache_trans hidden; Modified: trunk/libselinux/src/setrans_client.c =================================================================== --- trunk/libselinux/src/setrans_client.c 2007-03-12 15:34:29 UTC (rev 2288) +++ trunk/libselinux/src/setrans_client.c 2007-03-12 16:45:03 UTC (rev 2289) @@ -24,8 +24,6 @@ static __thread security_context_t prev_r2t_trans = NULL; static __thread security_context_t prev_r2t_raw = NULL; -int cache_trans hidden = 1; - /* * setransd_open * @@ -203,12 +201,10 @@ hidden void fini_context_translations(void) { - if (cache_trans) { - free(prev_r2t_trans); - free(prev_r2t_raw); - free(prev_t2r_trans); - free(prev_t2r_raw); - } + free(prev_r2t_trans); + free(prev_r2t_raw); + free(prev_t2r_trans); + free(prev_t2r_raw); } hidden int init_context_translations(void) @@ -230,29 +226,26 @@ goto out; } - if (cache_trans) { - if (prev_t2r_trans && strcmp(prev_t2r_trans, trans) == 0) { - *rawp = strdup(prev_t2r_raw); - } else { - free(prev_t2r_trans); - prev_t2r_trans = NULL; - free(prev_t2r_raw); - prev_t2r_raw = NULL; - if (trans_to_raw_context(trans, rawp)) - *rawp = strdup(trans); - if (*rawp) { - prev_t2r_trans = strdup(trans); - if (!prev_t2r_trans) - goto out; - prev_t2r_raw = strdup(*rawp); - if (!prev_t2r_raw) { - free(prev_t2r_trans); - prev_t2r_trans = NULL; - } + if (prev_t2r_trans && strcmp(prev_t2r_trans, trans) == 0) { + *rawp = strdup(prev_t2r_raw); + } else { + free(prev_t2r_trans); + prev_t2r_trans = NULL; + free(prev_t2r_raw); + prev_t2r_raw = NULL; + if (trans_to_raw_context(trans, rawp)) + *rawp = strdup(trans); + if (*rawp) { + prev_t2r_trans = strdup(trans); + if (!prev_t2r_trans) + goto out; + prev_t2r_raw = strdup(*rawp); + if (!prev_t2r_raw) { + free(prev_t2r_trans); + prev_t2r_trans = NULL; } } - } else if (trans_to_raw_context(trans, rawp)) - *rawp = strdup(trans); + } out: return *rawp ? 0 : -1; } @@ -272,29 +265,26 @@ goto out; } - if (cache_trans) { - if (prev_r2t_raw && strcmp(prev_r2t_raw, raw) == 0) { - *transp = strdup(prev_r2t_trans); - } else { - free(prev_r2t_raw); - prev_r2t_raw = NULL; - free(prev_r2t_trans); - prev_r2t_trans = NULL; - if (raw_to_trans_context(raw, transp)) - *transp = strdup(raw); - if (*transp) { - prev_r2t_raw = strdup(raw); - if (!prev_r2t_raw) - goto out; - prev_r2t_trans = strdup(*transp); - if (!prev_r2t_trans) { - free(prev_r2t_raw); - prev_r2t_raw = NULL; - } + if (prev_r2t_raw && strcmp(prev_r2t_raw, raw) == 0) { + *transp = strdup(prev_r2t_trans); + } else { + free(prev_r2t_raw); + prev_r2t_raw = NULL; + free(prev_r2t_trans); + prev_r2t_trans = NULL; + if (raw_to_trans_context(raw, transp)) + *transp = strdup(raw); + if (*transp) { + prev_r2t_raw = strdup(raw); + if (!prev_r2t_raw) + goto out; + prev_r2t_trans = strdup(*transp); + if (!prev_r2t_trans) { + free(prev_r2t_raw); + prev_r2t_raw = NULL; } } - } else if (raw_to_trans_context(raw, transp)) - *transp = strdup(raw); + } out: return *transp ? 0 : -1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2007-04-05 20:00:56
|
Revision: 2322 http://svn.sourceforge.net/selinux/?rev=2322&view=rev Author: ssmalley Date: 2007-04-05 13:00:54 -0700 (Thu, 05 Apr 2007) Log Message: ----------- Author: Eamon Walsh Email: ew...@ty... Subject: libselinux: grant permissions on deny in permissive mode Date: Thu, 05 Apr 2007 14:37:22 -0400 This patch duplicates the kernel behavior of granting permissions after a denial to avoid repeated AVC's, including flushing the cache on a switch to enforcing mode. Signed-off-by: Eamon Walsh <ew...@ty...> Modified Paths: -------------- trunk/libselinux/src/avc.c trunk/libselinux/src/avc_internal.c Modified: trunk/libselinux/src/avc.c =================================================================== --- trunk/libselinux/src/avc.c 2007-04-05 18:18:47 UTC (rev 2321) +++ trunk/libselinux/src/avc.c 2007-04-05 20:00:54 UTC (rev 2322) @@ -984,9 +984,12 @@ denied = requested & ~(ae->avd.allowed); - if ((!requested || denied) && avc_enforcing) { - errno = EACCES; - rc = -1; + if (!requested || denied) { + if (avc_enforcing) { + errno = EACCES; + rc = -1; + } else + ae->avd.allowed |= requested; } out: Modified: trunk/libselinux/src/avc_internal.c =================================================================== --- trunk/libselinux/src/avc_internal.c 2007-04-05 18:18:47 UTC (rev 2321) +++ trunk/libselinux/src/avc_internal.c 2007-04-05 20:00:54 UTC (rev 2322) @@ -163,6 +163,12 @@ ("%s: received setenforce notice (enforcing=%d)\n", avc_prefix, msg->val); avc_enforcing = msg->val; + if (avc_enforcing && (rc = avc_ss_reset(0)) < 0) { + avc_log + ("%s: cache reset returned %d (errno %d)\n", + avc_prefix, rc, errno); + goto out; + } break; } @@ -263,6 +269,12 @@ ("%s: received setenforce notice (enforcing=%d)\n", avc_prefix, msg->val); avc_enforcing = msg->val; + if (avc_enforcing && (ret = avc_ss_reset(0)) < 0) { + avc_log + ("%s: cache reset returned %d (errno %d)\n", + avc_prefix, ret, errno); + goto out; + } break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2007-05-09 14:53:32
|
Revision: 2433 http://svn.sourceforge.net/selinux/?rev=2433&view=rev Author: ssmalley Date: 2007-05-09 07:53:30 -0700 (Wed, 09 May 2007) Log Message: ----------- Author: Daniel J Walsh Email: dw...@re... Subject: More swig changes for libselinux Date: Fri, 04 May 2007 09:25:12 -0400 Added get_context_list.h Acked-by: Stephen Smalley <sd...@ty...> Modified Paths: -------------- trunk/libselinux/src/selinux.py trunk/libselinux/src/selinuxswig.i trunk/libselinux/src/selinuxswig_wrap.c Modified: trunk/libselinux/src/selinux.py =================================================================== --- trunk/libselinux/src/selinux.py 2007-05-09 14:50:22 UTC (rev 2432) +++ trunk/libselinux/src/selinux.py 2007-05-09 14:53:30 UTC (rev 2433) @@ -48,8 +48,19 @@ del types +SELINUX_DEFAULTUSER = _selinux.SELINUX_DEFAULTUSER +get_ordered_context_list = _selinux.get_ordered_context_list +get_ordered_context_list_with_level = _selinux.get_ordered_context_list_with_level +get_default_context = _selinux.get_default_context +get_default_context_with_level = _selinux.get_default_context_with_level +get_default_context_with_role = _selinux.get_default_context_with_role +get_default_context_with_rolelevel = _selinux.get_default_context_with_rolelevel +query_user_context = _selinux.query_user_context +manual_user_enter_context = _selinux.manual_user_enter_context is_selinux_enabled = _selinux.is_selinux_enabled is_selinux_mls_enabled = _selinux.is_selinux_mls_enabled +freecon = _selinux.freecon +freeconary = _selinux.freeconary getcon = _selinux.getcon setcon = _selinux.setcon getpidcon = _selinux.getpidcon @@ -88,6 +99,8 @@ set_matchpathcon_flags = _selinux.set_matchpathcon_flags matchpathcon_init = _selinux.matchpathcon_init matchpathcon = _selinux.matchpathcon +matchpathcon_init_prefix = _selinux.matchpathcon_init_prefix +matchpathcon_fini = _selinux.matchpathcon_fini matchmediacon = _selinux.matchmediacon selinux_getenforcemode = _selinux.selinux_getenforcemode selinux_policy_root = _selinux.selinux_policy_root @@ -102,6 +115,7 @@ selinux_homedir_context_path = _selinux.selinux_homedir_context_path selinux_media_context_path = _selinux.selinux_media_context_path selinux_contexts_path = _selinux.selinux_contexts_path +selinux_securetty_types_path = _selinux.selinux_securetty_types_path selinux_booleans_path = _selinux.selinux_booleans_path selinux_customizable_types_path = _selinux.selinux_customizable_types_path selinux_users_path = _selinux.selinux_users_path @@ -109,13 +123,16 @@ selinux_translations_path = _selinux.selinux_translations_path selinux_netfilter_context_path = _selinux.selinux_netfilter_context_path selinux_path = _selinux.selinux_path -selinux_check_passwd_access = _selinux.selinux_check_passwd_access -checkPasswdAccess = _selinux.checkPasswdAccess +selinux_check_securetty_context = _selinux.selinux_check_securetty_context +set_selinuxmnt = _selinux.set_selinuxmnt rpm_execcon = _selinux.rpm_execcon is_context_customizable = _selinux.is_context_customizable selinux_trans_to_raw_context = _selinux.selinux_trans_to_raw_context selinux_raw_to_trans_context = _selinux.selinux_raw_to_trans_context selinux_getpolicytype = _selinux.selinux_getpolicytype getseuserbyname = _selinux.getseuserbyname +selinux_file_context_cmp = _selinux.selinux_file_context_cmp +selinux_file_context_verify = _selinux.selinux_file_context_verify +selinux_lsetfilecon_default = _selinux.selinux_lsetfilecon_default Modified: trunk/libselinux/src/selinuxswig.i =================================================================== --- trunk/libselinux/src/selinuxswig.i 2007-05-09 14:50:22 UTC (rev 2432) +++ trunk/libselinux/src/selinuxswig.i 2007-05-09 14:53:30 UTC (rev 2433) @@ -21,6 +21,7 @@ %module selinux %{ #include "selinux/selinux.h" + #include "selinux/get_context_list.h" %} %apply int *OUTPUT { int * }; %apply int *OUTPUT { size_t * }; @@ -42,8 +43,12 @@ %typedef unsigned mode_t; +%include "../include/selinux/get_context_list.h" + extern int is_selinux_enabled(void); extern int is_selinux_mls_enabled(void); +extern void freecon(security_context_t con); +extern void freeconary(security_context_t * con); extern int getcon(security_context_t *con); extern int setcon(security_context_t con); extern int getpidcon(int pid, security_context_t *con); @@ -90,6 +95,11 @@ mode_t mode, security_context_t *con); +extern int matchpathcon_init_prefix(const char *path, + const char *prefix); +extern void matchpathcon_fini(void); + + extern int matchmediacon(const char *media, security_context_t *con); @@ -106,6 +116,7 @@ extern const char *selinux_homedir_context_path(void); extern const char *selinux_media_context_path(void); extern const char *selinux_contexts_path(void); +extern const char *selinux_securetty_types_path(void); extern const char *selinux_booleans_path(void); extern const char *selinux_customizable_types_path(void); extern const char *selinux_users_path(void); @@ -113,11 +124,15 @@ extern const char *selinux_translations_path(void); extern const char *selinux_netfilter_context_path(void); extern const char *selinux_path(void); -extern int selinux_check_passwd_access(access_vector_t requested); -extern int checkPasswdAccess(access_vector_t requested); +#extern int selinux_check_passwd_access(access_vector_t requested); +#extern int checkPasswdAccess(access_vector_t requested); +extern int selinux_check_securetty_context(security_context_t tty_context); +void set_selinuxmnt(char *mnt); + +#ifdef SWIGpython // This tells SWIG to treat char ** as a special case -%typemap(python,in) char ** { +%typemap(in) char ** { /* Check if is a list */ if (PyList_Check($input)) { int size = PyList_Size($input); @@ -143,6 +158,7 @@ return NULL; } } +#endif extern int rpm_execcon(unsigned int verified, const char *filename, @@ -164,3 +180,7 @@ } extern int selinux_getpolicytype(char **enforce); extern int getseuserbyname(const char *linuxuser, char **seuser, char **level); + +int selinux_file_context_cmp(const security_context_t a, const security_context_t b); +int selinux_file_context_verify(const char *path, mode_t mode); +int selinux_lsetfilecon_default(const char *path); Modified: trunk/libselinux/src/selinuxswig_wrap.c =================================================================== --- trunk/libselinux/src/selinuxswig_wrap.c 2007-05-09 14:50:22 UTC (rev 2432) +++ trunk/libselinux/src/selinuxswig_wrap.c 2007-05-09 14:53:30 UTC (rev 2433) @@ -2449,11 +2449,11 @@ /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_SELboolean swig_types[0] -#define SWIGTYPE_p_access_vector_t swig_types[1] -#define SWIGTYPE_p_char swig_types[2] -#define SWIGTYPE_p_int swig_types[3] -#define SWIGTYPE_p_p_char swig_types[4] -#define SWIGTYPE_p_p_p_char swig_types[5] +#define SWIGTYPE_p_char swig_types[1] +#define SWIGTYPE_p_int swig_types[2] +#define SWIGTYPE_p_p_char swig_types[3] +#define SWIGTYPE_p_p_p_char swig_types[4] +#define SWIGTYPE_p_p_security_context_t swig_types[5] #define SWIGTYPE_p_security_context_t swig_types[6] #define SWIGTYPE_p_unsigned_int swig_types[7] static swig_type_info *swig_types[9]; @@ -2485,8 +2485,101 @@ #include "selinux/selinux.h" + #include "selinux/get_context_list.h" +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); + } else { + return PyString_FromStringAndSize(carray, (int)(size)); + } + } else { + return SWIG_Py_Void(); + } +} + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ + if (PyString_Check(obj)) { + char *cstr; Py_ssize_t len; + PyString_AsStringAndSize(obj, &cstr, &len); + if (cptr) { + if (alloc) { + /* + In python the user should not be able to modify the inner + string representation. To warranty that, if you define + SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string + buffer is always returned. + + The default behavior is just to return the pointer value, + so, be careful. + */ +#if defined(SWIG_PYTHON_SAFE_CSTRINGS) + if (*alloc != SWIG_OLDOBJ) +#else + if (*alloc == SWIG_NEWOBJ) +#endif + { + *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + *alloc = SWIG_NEWOBJ; + } + else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } else { + *cptr = PyString_AsString(obj); + } + } + if (psize) *psize = len + 1; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + #define SWIG_From_long PyInt_FromLong @@ -2644,75 +2737,7 @@ } -SWIGINTERN swig_type_info* -SWIG_pchar_descriptor(void) -{ - static int init = 0; - static swig_type_info* info = 0; - if (!init) { - info = SWIG_TypeQuery("_p_char"); - init = 1; - } - return info; -} - - SWIGINTERN int -SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) -{ - if (PyString_Check(obj)) { - char *cstr; Py_ssize_t len; - PyString_AsStringAndSize(obj, &cstr, &len); - if (cptr) { - if (alloc) { - /* - In python the user should not be able to modify the inner - string representation. To warranty that, if you define - SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string - buffer is always returned. - - The default behavior is just to return the pointer value, - so, be careful. - */ -#if defined(SWIG_PYTHON_SAFE_CSTRINGS) - if (*alloc != SWIG_OLDOBJ) -#else - if (*alloc == SWIG_NEWOBJ) -#endif - { - *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); - *alloc = SWIG_NEWOBJ; - } - else { - *cptr = cstr; - *alloc = SWIG_OLDOBJ; - } - } else { - *cptr = PyString_AsString(obj); - } - } - if (psize) *psize = len + 1; - return SWIG_OK; - } else { - swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); - if (pchar_descriptor) { - void* vptr = 0; - if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { - if (cptr) *cptr = (char *) vptr; - if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; - if (alloc) *alloc = SWIG_OLDOBJ; - return SWIG_OK; - } - } - } - return SWIG_TypeError; -} - - - - - -SWIGINTERN int SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) { if (PyInt_Check(obj)) { @@ -2781,33 +2806,396 @@ return res; } +#ifdef __cplusplus +extern "C" { +#endif +SWIGINTERN PyObject *_wrap_get_ordered_context_list(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + security_context_t arg2 ; + security_context_t **arg3 = (security_context_t **) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:get_ordered_context_list",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_ordered_context_list" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + { + arg2 = (security_context_t)PyString_AsString(obj1); + } + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_p_security_context_t, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "get_ordered_context_list" "', argument " "3"" of type '" "security_context_t **""'"); + } + arg3 = (security_context_t **)(argp3); + result = (int)get_ordered_context_list((char const *)arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} -SWIGINTERNINLINE PyObject * -SWIG_FromCharPtrAndSize(const char* carray, size_t size) -{ - if (carray) { - if (size > INT_MAX) { - swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); - return pchar_descriptor ? - SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); - } else { - return PyString_FromStringAndSize(carray, (int)(size)); - } - } else { - return SWIG_Py_Void(); + +SWIGINTERN PyObject *_wrap_get_ordered_context_list_with_level(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + security_context_t arg3 ; + security_context_t **arg4 = (security_context_t **) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:get_ordered_context_list_with_level",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_ordered_context_list_with_level" "', argument " "1"" of type '" "char const *""'"); } + arg1 = (char *)(buf1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "get_ordered_context_list_with_level" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + { + arg3 = (security_context_t)PyString_AsString(obj2); + } + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_p_security_context_t, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "get_ordered_context_list_with_level" "', argument " "4"" of type '" "security_context_t **""'"); + } + arg4 = (security_context_t **)(argp4); + result = (int)get_ordered_context_list_with_level((char const *)arg1,(char const *)arg2,arg3,arg4); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; } -SWIGINTERNINLINE PyObject * -SWIG_FromCharPtr(const char *cptr) -{ - return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +SWIGINTERN PyObject *_wrap_get_default_context(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + security_context_t arg2 ; + security_context_t *arg3 = (security_context_t *) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + security_context_t temp3 = NULL ; + char *temp30 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + { + arg3 = &temp3; + } + if (!PyArg_ParseTuple(args,(char *)"OO:get_default_context",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_default_context" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + { + arg2 = (security_context_t)PyString_AsString(obj1); + } + result = (int)get_default_context((char const *)arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + { + if (*arg3) + temp30 = *arg3; + else + temp30 = ""; + resultobj = SWIG_Python_AppendOutput(resultobj, PyString_FromString(temp30)); + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; } -#ifdef __cplusplus -extern "C" { -#endif + +SWIGINTERN PyObject *_wrap_get_default_context_with_level(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + security_context_t arg3 ; + security_context_t *arg4 = (security_context_t *) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + security_context_t temp4 = NULL ; + char *temp40 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + { + arg4 = &temp4; + } + if (!PyArg_ParseTuple(args,(char *)"OOO:get_default_context_with_level",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_default_context_with_level" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "get_default_context_with_level" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + { + arg3 = (security_context_t)PyString_AsString(obj2); + } + result = (int)get_default_context_with_level((char const *)arg1,(char const *)arg2,arg3,arg4); + resultobj = SWIG_From_int((int)(result)); + { + if (*arg4) + temp40 = *arg4; + else + temp40 = ""; + resultobj = SWIG_Python_AppendOutput(resultobj, PyString_FromString(temp40)); + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_get_default_context_with_role(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + security_context_t arg3 ; + security_context_t *arg4 = (security_context_t *) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + security_context_t temp4 = NULL ; + char *temp40 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + { + arg4 = &temp4; + } + if (!PyArg_ParseTuple(args,(char *)"OOO:get_default_context_with_role",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_default_context_with_role" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "get_default_context_with_role" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + { + arg3 = (security_context_t)PyString_AsString(obj2); + } + result = (int)get_default_context_with_role((char const *)arg1,(char const *)arg2,arg3,arg4); + resultobj = SWIG_From_int((int)(result)); + { + if (*arg4) + temp40 = *arg4; + else + temp40 = ""; + resultobj = SWIG_Python_AppendOutput(resultobj, PyString_FromString(temp40)); + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_get_default_context_with_rolelevel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + security_context_t arg4 ; + security_context_t *arg5 = (security_context_t *) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + security_context_t temp5 = NULL ; + char *temp50 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + { + arg5 = &temp5; + } + if (!PyArg_ParseTuple(args,(char *)"OOOO:get_default_context_with_rolelevel",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_default_context_with_rolelevel" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "get_default_context_with_rolelevel" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "get_default_context_with_rolelevel" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + { + arg4 = (security_context_t)PyString_AsString(obj3); + } + result = (int)get_default_context_with_rolelevel((char const *)arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + resultobj = SWIG_From_int((int)(result)); + { + if (*arg5) + temp50 = *arg5; + else + temp50 = ""; + resultobj = SWIG_Python_AppendOutput(resultobj, PyString_FromString(temp50)); + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_query_user_context(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + security_context_t *arg2 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = NULL ; + security_context_t temp2 = NULL ; + char *temp10 = NULL ; + char *temp20 = NULL ; + + { + arg1 = &temp1; + } + { + arg2 = &temp2; + } + if (!PyArg_ParseTuple(args,(char *)":query_user_context")) SWIG_fail; + result = (int)query_user_context(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + { + if (*arg1) + temp10 = *arg1; + else + temp10 = ""; + resultobj = SWIG_Python_AppendOutput(resultobj, PyString_FromString(temp10)); + } + { + if (*arg2) + temp20 = *arg2; + else + temp20 = ""; + resultobj = SWIG_Python_AppendOutput(resultobj, PyString_FromString(temp20)); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_manual_user_enter_context(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + security_context_t *arg2 = (security_context_t *) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + security_context_t temp2 = NULL ; + char *temp20 = NULL ; + PyObject * obj0 = 0 ; + + { + arg2 = &temp2; + } + if (!PyArg_ParseTuple(args,(char *)"O:manual_user_enter_context",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "manual_user_enter_context" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + result = (int)manual_user_enter_context((char const *)arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + { + if (*arg2) + temp20 = *arg2; + else + temp20 = ""; + resultobj = SWIG_Python_AppendOutput(resultobj, PyString_FromString(temp20)); + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + SWIGINTERN PyObject *_wrap_is_selinux_enabled(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int result; @@ -2834,6 +3222,48 @@ } +SWIGINTERN PyObject *_wrap_freecon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:freecon",&obj0)) SWIG_fail; + { + arg1 = (security_context_t)PyString_AsString(obj0); + } + freecon(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_freeconary(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + security_context_t temp1 = NULL ; + char *temp10 = NULL ; + + { + arg1 = &temp1; + } + if (!PyArg_ParseTuple(args,(char *)":freeconary")) SWIG_fail; + freeconary(arg1); + resultobj = SWIG_Py_Void(); + { + if (*arg1) + temp10 = *arg1; + else + temp10 = ""; + resultobj = SWIG_Python_AppendOutput(resultobj, PyString_FromString(temp10)); + } + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_getcon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; security_context_t *arg1 = (security_context_t *) 0 ; @@ -3777,6 +4207,55 @@ } +SWIGINTERN PyObject *_wrap_matchpathcon_init_prefix(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:matchpathcon_init_prefix",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "matchpathcon_init_prefix" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "matchpathcon_init_prefix" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)matchpathcon_init_prefix((char const *)arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_matchpathcon_fini(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + + if (!PyArg_ParseTuple(args,(char *)":matchpathcon_fini")) SWIG_fail; + matchpathcon_fini(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_matchmediacon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; @@ -3994,6 +4473,19 @@ } +SWIGINTERN PyObject *_wrap_selinux_securetty_types_path(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":selinux_securetty_types_path")) SWIG_fail; + result = (char *)selinux_securetty_types_path(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_selinux_booleans_path(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; char *result = 0 ; @@ -4085,27 +4577,17 @@ } -SWIGINTERN PyObject *_wrap_selinux_check_passwd_access(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_selinux_check_securetty_context(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - access_vector_t arg1 ; + security_context_t arg1 ; int result; - void *argp1 ; - int res1 = 0 ; PyObject * obj0 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"O:selinux_check_passwd_access",&obj0)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"O:selinux_check_securetty_context",&obj0)) SWIG_fail; { - res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_access_vector_t, 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "selinux_check_passwd_access" "', argument " "1"" of type '" "access_vector_t""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "selinux_check_passwd_access" "', argument " "1"" of type '" "access_vector_t""'"); - } else { - arg1 = *((access_vector_t *)(argp1)); - } + arg1 = (security_context_t)PyString_AsString(obj0); } - result = (int)selinux_check_passwd_access(arg1); + result = (int)selinux_check_securetty_context(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -4113,30 +4595,26 @@ } -SWIGINTERN PyObject *_wrap_checkPasswdAccess(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_set_selinuxmnt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - access_vector_t arg1 ; - int result; - void *argp1 ; - int res1 = 0 ; + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; PyObject * obj0 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"O:checkPasswdAccess",&obj0)) SWIG_fail; - { - res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_access_vector_t, 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "checkPasswdAccess" "', argument " "1"" of type '" "access_vector_t""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "checkPasswdAccess" "', argument " "1"" of type '" "access_vector_t""'"); - } else { - arg1 = *((access_vector_t *)(argp1)); - } + if (!PyArg_ParseTuple(args,(char *)"O:set_selinuxmnt",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "set_selinuxmnt" "', argument " "1"" of type '" "char *""'"); } - result = (int)checkPasswdAccess(arg1); - resultobj = SWIG_From_int((int)(result)); + arg1 = (char *)(buf1); + set_selinuxmnt(arg1); + resultobj = SWIG_Py_Void(); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); return resultobj; fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); return NULL; } @@ -4153,6 +4631,10 @@ int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -4169,58 +4651,16 @@ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rpm_execcon" "', argument " "2"" of type '" "char const *""'"); } arg2 = (char *)(buf2); - { - /* Check if is a list */ - if (PyList_Check(obj2)) { - int size = PyList_Size(obj2); - int i = 0; - arg3 = (char **) malloc((size+1)*sizeof(char *)); - if (arg3 == NULL) { - PyErr_SetString(PyExc_MemoryError,"Out of memory"); - return NULL; - } - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem(obj2,i); - if (PyString_Check(o)) - arg3[i] = PyString_AsString(PyList_GetItem(obj2,i)); - else { - PyErr_SetString(PyExc_TypeError,"list must contain strings"); - free(arg3); - return NULL; - } - } - arg3[i] = 0; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_p_char, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "rpm_execcon" "', argument " "3"" of type '" "char **""'"); } - { - /* Check if is a list */ - if (PyList_Check(obj3)) { - int size = PyList_Size(obj3); - int i = 0; - arg4 = (char **) malloc((size+1)*sizeof(char *)); - if (arg4 == NULL) { - PyErr_SetString(PyExc_MemoryError,"Out of memory"); - return NULL; - } - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem(obj3,i); - if (PyString_Check(o)) - arg4[i] = PyString_AsString(PyList_GetItem(obj3,i)); - else { - PyErr_SetString(PyExc_TypeError,"list must contain strings"); - free(arg4); - return NULL; - } - } - arg4[i] = 0; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } + arg3 = (char **)(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_p_char, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "rpm_execcon" "', argument " "4"" of type '" "char **""'"); } + arg4 = (char **)(argp4); result = (int)rpm_execcon(arg1,(char const *)arg2,arg3,arg4); resultobj = SWIG_From_int((int)(result)); if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); @@ -4387,9 +4827,101 @@ } +SWIGINTERN PyObject *_wrap_selinux_file_context_cmp(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 ; + security_context_t arg2 ; + int result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:selinux_file_context_cmp",&obj0,&obj1)) SWIG_fail; + { + arg1 = (security_context_t)PyString_AsString(obj0); + } + { + arg2 = (security_context_t)PyString_AsString(obj1); + } + result = (int)selinux_file_context_cmp(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_selinux_file_context_verify(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + mode_t arg2 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:selinux_file_context_verify",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "selinux_file_context_verify" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "selinux_file_context_verify" "', argument " "2"" of type '" "mode_t""'"); + } + arg2 = (mode_t)(val2); + result = (int)selinux_file_context_verify((char const *)arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_selinux_lsetfilecon_default(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:selinux_lsetfilecon_default",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "selinux_lsetfilecon_default" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + result = (int)selinux_lsetfilecon_default((char const *)arg1); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + static PyMethodDef SwigMethods[] = { + { (char *)"get_ordered_context_list", _wrap_get_ordered_context_list, METH_VARARGS, NULL}, + { (char *)"get_ordered_context_list_with_level", _wrap_get_ordered_context_list_with_level, METH_VARARGS, NULL}, + { (char *)"get_default_context", _wrap_get_default_context, METH_VARARGS, NULL}, + { (char *)"get_default_context_with_level", _wrap_get_default_context_with_level, METH_VARARGS, NULL}, + { (char *)"get_default_context_with_role", _wrap_get_default_context_with_role, METH_VARARGS, NULL}, + { (char *)"get_default_context_with_rolelevel", _wrap_get_default_context_with_rolelevel, METH_VARARGS, NULL}, + { (char *)"query_user_context", _wrap_query_user_context, METH_VARARGS, NULL}, + { (char *)"manual_user_enter_context", _wrap_manual_user_enter_context, METH_VARARGS, NULL}, { (char *)"is_selinux_enabled", _wrap_is_selinux_enabled, METH_VARARGS, NULL}, { (char *)"is_selinux_mls_enabled", _wrap_is_selinux_mls_enabled, METH_VARARGS, NULL}, + { (char *)"freecon", _wrap_freecon, METH_VARARGS, NULL}, + { (char *)"freeconary", _wrap_freeconary, METH_VARARGS, NULL}, { (char *)"getcon", _wrap_getcon, METH_VARARGS, NULL}, { (char *)"setcon", _wrap_setcon, METH_VARARGS, NULL}, { (char *)"getpidcon", _wrap_getpidcon, METH_VARARGS, NULL}, @@ -4426,6 +4958,8 @@ { (char *)"set_matchpathcon_flags", _wrap_set_matchpathcon_flags, METH_VARARGS, NULL}, { (char *)"matchpathcon_init", _wrap_matchpathcon_init, METH_VARARGS, NULL}, { (char *)"matchpathcon", _wrap_matchpathcon, METH_VARARGS, NULL}, + { (char *)"matchpathcon_init_prefix", _wrap_matchpathcon_init_prefix, METH_VARARGS, NULL}, + { (char *)"matchpathcon_fini", _wrap_matchpathcon_fini, METH_VARARGS, NULL}, { (char *)"matchmediacon", _wrap_matchmediacon, METH_VARARGS, NULL}, { (char *)"selinux_getenforcemode", _wrap_selinux_getenforcemode, METH_VARARGS, NULL}, { (char *)"selinux_policy_root", _wrap_selinux_policy_root, METH_VARARGS, NULL}, @@ -4440,6 +4974,7 @@ { (char *)"selinux_homedir_context_path", _wrap_selinux_homedir_context_path, METH_VARARGS, NULL}, { (char *)"selinux_media_context_path", _wrap_selinux_media_context_path, METH_VARARGS, NULL}, { (char *)"selinux_contexts_path", _wrap_selinux_contexts_path, METH_VARARGS, NULL}, + { (char *)"selinux_securetty_types_path", _wrap_selinux_securetty_types_path, METH_VARARGS, NULL}, { (char *)"selinux_booleans_path", _wrap_selinux_booleans_path, METH_VARARGS, NULL}, { (char *)"selinux_customizable_types_path", _wrap_selinux_customizable_types_path, METH_VARARGS, NULL}, { (char *)"selinux_users_path", _wrap_selinux_users_path, METH_VARARGS, NULL}, @@ -4447,14 +4982,17 @@ { (char *)"selinux_translations_path", _wrap_selinux_translations_path, METH_VARARGS, NULL}, { (char *)"selinux_netfilter_context_path", _wrap_selinux_netfilter_context_path, METH_VARARGS, NULL}, { (char *)"selinux_path", _wrap_selinux_path, METH_VARARGS, NULL}, - { (char *)"selinux_check_passwd_access", _wrap_selinux_check_passwd_access, METH_VARARGS, NULL}, - { (char *)"checkPasswdAccess", _wrap_checkPasswdAccess, METH_VARARGS, NULL}, + { (char *)"selinux_check_securetty_context", _wrap_selinux_check_securetty_context, METH_VARARGS, NULL}, + { (char *)"set_selinuxmnt", _wrap_set_selinuxmnt, METH_VARARGS, NULL}, { (char *)"rpm_execcon", _wrap_rpm_execcon, METH_VARARGS, NULL}, { (char *)"is_context_customizable", _wrap_is_context_customizable, METH_VARARGS, NULL}, { (char *)"selinux_trans_to_raw_context", _wrap_selinux_trans_to_raw_context, METH_VARARGS, NULL}, { (char *)"selinux_raw_to_trans_context", _wrap_selinux_raw_to_trans_context, METH_VARARGS, NULL}, { (char *)"selinux_getpolicytype", _wrap_selinux_getpolicytype, METH_VARARGS, NULL}, { (char *)"getseuserbyname", _wrap_getseuserbyname, METH_VARARGS, NULL}, + { (char *)"selinux_file_context_cmp", _wrap_selinux_file_context_cmp, METH_VARARGS, NULL}, + { (char *)"selinux_file_context_verify", _wrap_selinux_file_context_verify, METH_VARARGS, NULL}, + { (char *)"selinux_lsetfilecon_default", _wrap_selinux_lsetfilecon_default, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } }; @@ -4462,41 +5000,41 @@ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ static swig_type_info _swigt__p_SELboolean = {"_p_SELboolean", "SELboolean *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_access_vector_t = {"_p_access_vector_t", "access_vector_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_p_p_char = {"_p_p_p_char", "char ***", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_security_context_t = {"_p_p_security_context_t", "security_context_t **", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_security_context_t = {"_p_security_context_t", "security_context_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "unsigned int *|mode_t *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { &_swigt__p_SELboolean, - &_swigt__p_access_vector_t, &_swigt__p_char, &_swigt__p_int, &_swigt__p_p_char, &_swigt__p_p_p_char, + &_swigt__p_p_security_context_t, &_swigt__p_security_context_t, &_swigt__p_unsigned_int, }; static swig_cast_info _swigc__p_SELboolean[] = { {&_swigt__p_SELboolean, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_access_vector_t[] = { {&_swigt__p_access_vector_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_p_char[] = { {&_swigt__p_p_p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_security_context_t[] = { {&_swigt__p_p_security_context_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_security_context_t[] = { {&_swigt__p_security_context_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { _swigc__p_SELboolean, - _swigc__p_access_vector_t, _swigc__p_char, _swigc__p_int, _swigc__p_p_char, _swigc__p_p_p_char, + _swigc__p_p_security_context_t, _swigc__p_security_context_t, _swigc__p_unsigned_int, }; @@ -5019,6 +5557,7 @@ SWIG_InstallConstants(d,swig_const_table); + SWIG_Python_SetConstant(d, "SELINUX_DEFAULTUSER",SWIG_FromCharPtr("user_u")); SWIG_Python_SetConstant(d, "MATCHPATHCON_BASEONLY",SWIG_From_int((int)(1))); SWIG_Python_SetConstant(d, "MATCHPATHCON_NOTRANS",SWIG_From_int((int)(2))); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ew...@us...> - 2007-06-05 19:26:37
|
Revision: 2462 http://svn.sourceforge.net/selinux/?rev=2462&view=rev Author: ewalsh Date: 2007-06-05 12:26:35 -0700 (Tue, 05 Jun 2007) Log Message: ----------- Author: Eamon Walsh Email: ew...@ty... Subject: libselinux: string representation refactoring Date: Fri, 01 Jun 2007 18:15:56 -0400 This patch splits the string representation functions out of avc.c and refactors the AVC code to use the interface functions instead of the raw tables when building AVC messages. These changes should make it easier to add the dynamic class and permission support (Chris, take note). The "print_access_vector" function should probably be deprecated at some point. IIRC it was used by some utility that now doesn't use it anymore. Signed-off-by: Eamon Walsh <ew...@ty...> Acked-by: Stephen Smalley <sd...@ty...> Modified Paths: -------------- trunk/libselinux/src/avc.c Added Paths: ----------- trunk/libselinux/src/stringrep.c Modified: trunk/libselinux/src/avc.c =================================================================== --- trunk/libselinux/src/avc.c 2007-06-05 14:02:40 UTC (rev 2461) +++ trunk/libselinux/src/avc.c 2007-06-05 19:26:35 UTC (rev 2462) @@ -7,151 +7,13 @@ * Stephen Smalley <sd...@ep...> and * James Morris <jm...@re...>. */ -#include <sys/types.h> -#include <errno.h> -#include <stddef.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <stdint.h> -#include <selinux/flask.h> -#include "selinux_internal.h" #include <selinux/avc.h> +#include "selinux_internal.h" #include "avc_sidtab.h" #include "avc_internal.h" -#include <selinux/av_permissions.h> -/* The following code looks complicated, but it really is not. What it - does is to generate two variables. The first is basically a struct - of arrays. The second is the real array of structures which would - have used string pointers. But instead it now uses an offset value - into the first structure. Strings are accessed indirectly by an - explicit addition of the string index and the base address of the - structure with the strings (all type safe). The advantage is that - there are no relocations necessary in the array with the data as it - would be the case with string pointers. This has advantages at - load time, the data section is smaller, and it is read-only. */ -#define L1(line) L2(line) -#define L2(line) str##line -static const union av_perm_to_string_data { - struct { -#define S_(c, v, s) char L1(__LINE__)[sizeof(s)]; -#include "av_perm_to_string.h" -#undef S_ - }; - char str[0]; -} av_perm_to_string_data = { - { -#define S_(c, v, s) s, -#include "av_perm_to_string.h" -#undef S_ - } -}; -static const struct av_perm_to_string { - uint16_t tclass; - uint16_t nameidx; - uint32_t value; -} av_perm_to_string[] = { -#define S_(c, v, s) { c, offsetof(union av_perm_to_string_data, L1(__LINE__)), v }, -#include "av_perm_to_string.h" -#undef S_ -}; - -#undef L1 -#undef L2 - -#define L1(line) L2(line) -#define L2(line) str##line -static const union class_to_string_data { - struct { -#define S_(s) char L1(__LINE__)[sizeof(s)]; -#include "class_to_string.h" -#undef S_ - }; - char str[0]; -} class_to_string_data = { - { -#define S_(s) s, -#include "class_to_string.h" -#undef S_ - } -}; -static const uint16_t class_to_string[] = { -#define S_(s) offsetof(union class_to_string_data, L1(__LINE__)), -#include "class_to_string.h" -#undef S_ -}; - -#undef L1 -#undef L2 - -static const union common_perm_to_string_data { - struct { -#define L1(line) L2(line) -#define L2(line) str##line -#define S_(s) char L1(__LINE__)[sizeof(s)]; -#define TB_(s) -#define TE_(s) -#include "common_perm_to_string.h" -#undef S_ -#undef L1 -#undef L2 - }; - char str[0]; -} common_perm_to_string_data = { - { -#define S_(s) s, -#include "common_perm_to_string.h" -#undef S_ -#undef TB_ -#undef TE_ - } -}; -static const union common_perm_to_string { - struct { -#define TB_(s) struct { -#define TE_(s) } s##_part; -#define S_(s) uint16_t L1(__LINE__) -#define L1(l) L2(l) -#define L2(l) field_##l; -#include "common_perm_to_string.h" -#undef TB_ -#undef TE_ -#undef S_ -#undef L1 -#undef L2 - }; - uint16_t data[0]; -} common_perm_to_string = { - { -#define TB_(s) { -#define TE_(s) }, -#define S_(s) offsetof(union common_perm_to_string_data, L1(__LINE__)), -#define L1(line) L2(line) -#define L2(line) str##line -#include "common_perm_to_string.h" -#undef TB_ -#undef TE_ -#undef S_ -#undef L1 -#undef L2 - } -}; - -static const struct av_inherit { - uint16_t tclass; - uint16_t common_pts_idx; - uint32_t common_base; -} av_inherit[] = { -#define S_(c, i, b) { c, offsetof(union common_perm_to_string, common_##i##_perm_to_string_part)/sizeof(uint16_t), b }, -#include "av_inherit.h" -#undef S_ -}; - #define AVC_CACHE_SLOTS 512 #define AVC_CACHE_MAXNODES 410 -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) struct avc_entry { security_id_t ssid; @@ -812,56 +674,27 @@ */ static void avc_dump_av(security_class_t tclass, access_vector_t av) { - const uint16_t *common_pts_idx = 0; - uint32_t common_base = 0, perm; - unsigned int i, i2; + const char *permstr; + access_vector_t bit = 1; if (av == 0) { log_append(avc_audit_buf, " null"); return; } - for (i = 0; i < ARRAY_SIZE(av_inherit); i++) { - if (av_inherit[i].tclass == tclass) { - common_pts_idx = - &common_perm_to_string.data[av_inherit[i]. - common_pts_idx]; - common_base = av_inherit[i].common_base; - break; - } - } - log_append(avc_audit_buf, " {"); - i = 0; - perm = 1; - while (perm < common_base) { - if (perm & av) { - log_append(avc_audit_buf, " %s", - common_perm_to_string_data.str + - common_pts_idx[i]); - av &= ~perm; - } - i++; - perm <<= 1; - } - while (i < sizeof(av) * 8) { - if (perm & av) { - for (i2 = 0; i2 < ARRAY_SIZE(av_perm_to_string); i2++) { - if ((av_perm_to_string[i2].tclass == tclass) && - (av_perm_to_string[i2].value == perm)) - break; - } - if (i2 < ARRAY_SIZE(av_perm_to_string)) { - log_append(avc_audit_buf, " %s", - av_perm_to_string_data.str + - av_perm_to_string[i2].nameidx); - av &= ~perm; - } + while (av) { + if (av & bit) { + permstr = security_av_perm_to_string(tclass, bit); + if (!permstr) + break; + log_append(avc_audit_buf, " %s", permstr); + av &= ~bit; } - i++; - perm <<= 1; + bit <<= 1; } + if (av) log_append(avc_audit_buf, " 0x%x", av); log_append(avc_audit_buf, " }"); @@ -890,7 +723,7 @@ avc_release_lock(avc_lock); log_append(avc_audit_buf, " tclass=%s", - class_to_string_data.str + class_to_string[tclass]); + security_class_to_string(tclass)); } void avc_audit(security_id_t ssid, security_id_t tsid, @@ -1318,218 +1151,3 @@ return avc_control(AVC_CALLBACK_AUDITDENY_DISABLE, ssid, tsid, tclass, perms, seqno, 0); } - -/* Other exported functions that use the string tables, - formerly in helpers.c. */ - -#include <ctype.h> - -#define NCLASSES ARRAY_SIZE(class_to_string) -#define NVECTORS ARRAY_SIZE(av_perm_to_string) - -security_class_t string_to_security_class(const char *s) -{ - unsigned int val; - - if (isdigit(s[0])) { - val = atoi(s); - if (val > 0 && val < NCLASSES) - return val; - } else { - for (val = 0; val < NCLASSES; val++) { - if (strcmp(s, (class_to_string_data.str - + class_to_string[val])) == 0) - return val; - } - } - - return 0; -} - -access_vector_t string_to_av_perm(security_class_t tclass, const char *s) -{ - const uint16_t *common_pts_idx = 0; - access_vector_t perm, common_base = 0; - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(av_inherit); i++) { - if (av_inherit[i].tclass == tclass) { - common_pts_idx = - &common_perm_to_string.data[av_inherit[i]. - common_pts_idx]; - common_base = av_inherit[i].common_base; - break; - } - } - - i = 0; - perm = 1; - while (perm < common_base) { - if (strcmp - (s, - common_perm_to_string_data.str + common_pts_idx[i]) == 0) - return perm; - perm <<= 1; - i++; - } - - for (i = 0; i < NVECTORS; i++) { - if ((av_perm_to_string[i].tclass == tclass) && - (strcmp(s, (av_perm_to_string_data.str - + av_perm_to_string[i].nameidx)) == 0)) - return av_perm_to_string[i].value; - } - - return 0; -} - -const char *security_class_to_string(security_class_t tclass) -{ - tclass = (tclass > 0 && tclass < NCLASSES) ? tclass : 0; - return class_to_string_data.str + class_to_string[tclass]; -} - -const char *security_av_perm_to_string(security_class_t tclass, - access_vector_t av) -{ - const uint16_t *common_pts_idx = 0; - access_vector_t common_base = 0; - unsigned int i; - - if (!av) - return NULL; - - for (i = 0; i < ARRAY_SIZE(av_inherit); i++) { - if (av_inherit[i].tclass == tclass) { - common_pts_idx = - &common_perm_to_string.data[av_inherit[i]. - common_pts_idx]; - common_base = av_inherit[i].common_base; - break; - } - } - - if (av < common_base) { - i = 0; - while (!(av & 1)) { - av >>= 1; - i++; - } - return common_perm_to_string_data.str + common_pts_idx[i]; - } - - for (i = 0; i < NVECTORS; i++) { - if (av_perm_to_string[i].tclass == tclass && - av_perm_to_string[i].value == av) - return av_perm_to_string_data.str - + av_perm_to_string[i].nameidx; - } - - return NULL; -} - -int security_av_string(security_class_t tclass, access_vector_t av, char **res) -{ - unsigned int i = 0; - size_t len = 5; - access_vector_t tmp = av; - int rc = 0; - const char *str; - char *ptr; - - /* first pass computes the required length */ - while (tmp) { - if (tmp & 1) { - str = security_av_perm_to_string(tclass, av & (1<<i)); - if (str) - len += strlen(str) + 1; - else { - rc = -1; - errno = EINVAL; - goto out; - } - } - tmp >>= 1; - i++; - } - - *res = malloc(len); - if (!*res) { - rc = -1; - goto out; - } - - /* second pass constructs the string */ - i = 0; - tmp = av; - ptr = *res; - - if (!av) { - sprintf(ptr, "null"); - goto out; - } - - ptr += sprintf(ptr, "{ "); - while (tmp) { - if (tmp & 1) - ptr += sprintf(ptr, "%s ", security_av_perm_to_string( - tclass, av & (1<<i))); - tmp >>= 1; - i++; - } - sprintf(ptr, "}"); -out: - return rc; -} - -void print_access_vector(security_class_t tclass, access_vector_t av) -{ - const uint16_t *common_pts_idx = 0; - access_vector_t common_base = 0; - unsigned int i, i2, perm; - - if (av == 0) { - printf(" null"); - return; - } - - for (i = 0; i < ARRAY_SIZE(av_inherit); i++) { - if (av_inherit[i].tclass == tclass) { - common_pts_idx = - &common_perm_to_string.data[av_inherit[i]. - common_pts_idx]; - common_base = av_inherit[i].common_base; - break; - } - } - - printf(" {"); - i = 0; - perm = 1; - while (perm < common_base) { - if (perm & av) - printf(" %s", - common_perm_to_string_data.str + - common_pts_idx[i]); - i++; - perm <<= 1; - } - - while (i < sizeof(access_vector_t) * 8) { - if (perm & av) { - for (i2 = 0; i2 < NVECTORS; i2++) { - if ((av_perm_to_string[i2].tclass == tclass) && - (av_perm_to_string[i2].value == perm)) - break; - } - if (i2 < NVECTORS) - printf(" %s", - av_perm_to_string_data.str - + av_perm_to_string[i2].nameidx); - } - i++; - perm <<= 1; - } - - printf(" }"); -} Added: trunk/libselinux/src/stringrep.c =================================================================== --- trunk/libselinux/src/stringrep.c (rev 0) +++ trunk/libselinux/src/stringrep.c 2007-06-05 19:26:35 UTC (rev 2462) @@ -0,0 +1,328 @@ +/* + * String representation support for classes and permissions. + */ +#include <errno.h> +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> +#include <ctype.h> +#include <selinux/flask.h> +#include <selinux/av_permissions.h> +#include "selinux_internal.h" + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +/* The following code looks complicated, but it really is not. What it + does is to generate two variables. The first is basically a struct + of arrays. The second is the real array of structures which would + have used string pointers. But instead it now uses an offset value + into the first structure. Strings are accessed indirectly by an + explicit addition of the string index and the base address of the + structure with the strings (all type safe). The advantage is that + there are no relocations necessary in the array with the data as it + would be the case with string pointers. This has advantages at + load time, the data section is smaller, and it is read-only. */ +#define L1(line) L2(line) +#define L2(line) str##line +static const union av_perm_to_string_data { + struct { +#define S_(c, v, s) char L1(__LINE__)[sizeof(s)]; +#include "av_perm_to_string.h" +#undef S_ + }; + char str[0]; +} av_perm_to_string_data = { + { +#define S_(c, v, s) s, +#include "av_perm_to_string.h" +#undef S_ + } +}; +static const struct av_perm_to_string { + uint16_t tclass; + uint16_t nameidx; + uint32_t value; +} av_perm_to_string[] = { +#define S_(c, v, s) { c, offsetof(union av_perm_to_string_data, L1(__LINE__)), v }, +#include "av_perm_to_string.h" +#undef S_ +}; + +#undef L1 +#undef L2 + +#define L1(line) L2(line) +#define L2(line) str##line +static const union class_to_string_data { + struct { +#define S_(s) char L1(__LINE__)[sizeof(s)]; +#include "class_to_string.h" +#undef S_ + }; + char str[0]; +} class_to_string_data = { + { +#define S_(s) s, +#include "class_to_string.h" +#undef S_ + } +}; +static const uint16_t class_to_string[] = { +#define S_(s) offsetof(union class_to_string_data, L1(__LINE__)), +#include "class_to_string.h" +#undef S_ +}; + +#undef L1 +#undef L2 + +static const union common_perm_to_string_data { + struct { +#define L1(line) L2(line) +#define L2(line) str##line +#define S_(s) char L1(__LINE__)[sizeof(s)]; +#define TB_(s) +#define TE_(s) +#include "common_perm_to_string.h" +#undef S_ +#undef L1 +#undef L2 + }; + char str[0]; +} common_perm_to_string_data = { + { +#define S_(s) s, +#include "common_perm_to_string.h" +#undef S_ +#undef TB_ +#undef TE_ + } +}; +static const union common_perm_to_string { + struct { +#define TB_(s) struct { +#define TE_(s) } s##_part; +#define S_(s) uint16_t L1(__LINE__) +#define L1(l) L2(l) +#define L2(l) field_##l; +#include "common_perm_to_string.h" +#undef TB_ +#undef TE_ +#undef S_ +#undef L1 +#undef L2 + }; + uint16_t data[0]; +} common_perm_to_string = { + { +#define TB_(s) { +#define TE_(s) }, +#define S_(s) offsetof(union common_perm_to_string_data, L1(__LINE__)), +#define L1(line) L2(line) +#define L2(line) str##line +#include "common_perm_to_string.h" +#undef TB_ +#undef TE_ +#undef S_ +#undef L1 +#undef L2 + } +}; + +static const struct av_inherit { + uint16_t tclass; + uint16_t common_pts_idx; + uint32_t common_base; +} av_inherit[] = { +#define S_(c, i, b) { c, offsetof(union common_perm_to_string, common_##i##_perm_to_string_part)/sizeof(uint16_t), b }, +#include "av_inherit.h" +#undef S_ +}; + +#define NCLASSES ARRAY_SIZE(class_to_string) +#define NVECTORS ARRAY_SIZE(av_perm_to_string) + +security_class_t string_to_security_class(const char *s) +{ + unsigned int val; + + if (isdigit(s[0])) { + val = atoi(s); + if (val > 0 && val < NCLASSES) + return val; + } else { + for (val = 0; val < NCLASSES; val++) { + if (strcmp(s, (class_to_string_data.str + + class_to_string[val])) == 0) + return val; + } + } + + return 0; +} + +access_vector_t string_to_av_perm(security_class_t tclass, const char *s) +{ + const uint16_t *common_pts_idx = 0; + access_vector_t perm, common_base = 0; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(av_inherit); i++) { + if (av_inherit[i].tclass == tclass) { + common_pts_idx = + &common_perm_to_string.data[av_inherit[i]. + common_pts_idx]; + common_base = av_inherit[i].common_base; + break; + } + } + + i = 0; + perm = 1; + while (perm < common_base) { + if (strcmp + (s, + common_perm_to_string_data.str + common_pts_idx[i]) == 0) + return perm; + perm <<= 1; + i++; + } + + for (i = 0; i < NVECTORS; i++) { + if ((av_perm_to_string[i].tclass == tclass) && + (strcmp(s, (av_perm_to_string_data.str + + av_perm_to_string[i].nameidx)) == 0)) + return av_perm_to_string[i].value; + } + + return 0; +} + +const char *security_class_to_string(security_class_t tclass) +{ + tclass = (tclass > 0 && tclass < NCLASSES) ? tclass : 0; + return class_to_string_data.str + class_to_string[tclass]; +} + +const char *security_av_perm_to_string(security_class_t tclass, + access_vector_t av) +{ + const uint16_t *common_pts_idx = 0; + access_vector_t common_base = 0; + unsigned int i; + + if (!av) + return NULL; + + for (i = 0; i < ARRAY_SIZE(av_inherit); i++) { + if (av_inherit[i].tclass == tclass) { + common_pts_idx = + &common_perm_to_string.data[av_inherit[i]. + common_pts_idx]; + common_base = av_inherit[i].common_base; + break; + } + } + + if (av < common_base) { + i = 0; + while (!(av & 1)) { + av >>= 1; + i++; + } + return common_perm_to_string_data.str + common_pts_idx[i]; + } + + for (i = 0; i < NVECTORS; i++) { + if (av_perm_to_string[i].tclass == tclass && + av_perm_to_string[i].value == av) + return av_perm_to_string_data.str + + av_perm_to_string[i].nameidx; + } + + return NULL; +} + +int security_av_string(security_class_t tclass, access_vector_t av, char **res) +{ + unsigned int i = 0; + size_t len = 5; + access_vector_t tmp = av; + int rc = 0; + const char *str; + char *ptr; + + /* first pass computes the required length */ + while (tmp) { + if (tmp & 1) { + str = security_av_perm_to_string(tclass, av & (1<<i)); + if (str) + len += strlen(str) + 1; + else { + rc = -1; + errno = EINVAL; + goto out; + } + } + tmp >>= 1; + i++; + } + + *res = malloc(len); + if (!*res) { + rc = -1; + goto out; + } + + /* second pass constructs the string */ + i = 0; + tmp = av; + ptr = *res; + + if (!av) { + sprintf(ptr, "null"); + goto out; + } + + ptr += sprintf(ptr, "{ "); + while (tmp) { + if (tmp & 1) + ptr += sprintf(ptr, "%s ", security_av_perm_to_string( + tclass, av & (1<<i))); + tmp >>= 1; + i++; + } + sprintf(ptr, "}"); +out: + return rc; +} + +void print_access_vector(security_class_t tclass, access_vector_t av) +{ + const char *permstr; + access_vector_t bit = 1; + + if (av == 0) { + printf(" null"); + return; + } + + printf(" {"); + + while (av) { + if (av & bit) { + permstr = security_av_perm_to_string(tclass, bit); + if (!permstr) + break; + printf(" %s", permstr); + av &= ~bit; + } + bit <<= 1; + } + + if (av) + printf(" 0x%x", av); + printf(" }"); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ew...@us...> - 2007-06-07 18:41:16
|
Revision: 2468 http://svn.sourceforge.net/selinux/?rev=2468&view=rev Author: ewalsh Date: 2007-06-07 11:41:15 -0700 (Thu, 07 Jun 2007) Log Message: ----------- Author: "Christopher J. PeBenito" Email: cpe...@tr... Subject: libselinux: add checking for kernel object class discovery Date: Thu, 07 Jun 2007 13:41:58 +0000 Detect if object class discovery kernel support exists. Fall back to hardcoded values for compatibility. Signed-off-by: Chris PeBenito <cpe...@tr...> Acked-by: Eamon Walsh <ew...@ty...> Modified Paths: -------------- trunk/libselinux/src/init.c trunk/libselinux/src/stringrep.c Modified: trunk/libselinux/src/init.c =================================================================== --- trunk/libselinux/src/init.c 2007-06-07 18:40:51 UTC (rev 2467) +++ trunk/libselinux/src/init.c 2007-06-07 18:41:15 UTC (rev 2468) @@ -9,6 +9,7 @@ #include <dlfcn.h> #include <sys/vfs.h> #include <stdint.h> +#include <limits.h> #include "dso.h" #include "policy.h" @@ -17,6 +18,7 @@ char *selinux_mnt = NULL; int selinux_page_size = 0; +int obj_class_compat = 1; static void init_selinuxmnt(void) { @@ -87,11 +89,33 @@ hidden_def(set_selinuxmnt) +static void init_obj_class_compat(void) +{ + char path[PATH_MAX]; + struct stat s; + + if (!selinux_mnt) + return; + + snprintf(path,PATH_MAX,"%s/class",selinux_mnt); + if (stat(path,&s) < 0) + return; + + if (S_ISDIR(s.st_mode)) + obj_class_compat = 0; +} + +static void fini_obj_class_compat(void) +{ + obj_class_compat = 1; +} + static void init_lib(void) __attribute__ ((constructor)); static void init_lib(void) { selinux_page_size = sysconf(_SC_PAGE_SIZE); init_selinuxmnt(); + init_obj_class_compat(); init_context_translations(); } @@ -99,5 +123,6 @@ static void fini_lib(void) { fini_selinuxmnt(); + fini_obj_class_compat(); fini_context_translations(); } Modified: trunk/libselinux/src/stringrep.c =================================================================== --- trunk/libselinux/src/stringrep.c 2007-06-07 18:40:51 UTC (rev 2467) +++ trunk/libselinux/src/stringrep.c 2007-06-07 18:41:15 UTC (rev 2468) @@ -151,6 +151,8 @@ #define NVECTORS ARRAY_SIZE(av_perm_to_string) #define MAXVECTORS 8*sizeof(access_vector_t) +extern int obj_class_compat; + struct discover_class_node { char *name; security_class_t value; @@ -417,6 +419,9 @@ { struct discover_class_node *node; + if (obj_class_compat) + return string_to_security_class_compat(s); + node = get_class_cache_entry_name(s); if (node == NULL) { node = discover_class(s); @@ -434,6 +439,9 @@ { struct discover_class_node *node; + if (obj_class_compat) + return string_to_av_perm_compat(tclass,s); + node = get_class_cache_entry_value(tclass); if (node != NULL) { size_t i; @@ -450,6 +458,9 @@ { struct discover_class_node *node; + if (obj_class_compat) + return security_class_to_string_compat(tclass); + node = get_class_cache_entry_value(tclass); if (node == NULL) { errno = EINVAL; @@ -464,6 +475,9 @@ struct discover_class_node *node; size_t i; + if (obj_class_compat) + return security_av_perm_to_string_compat(tclass,av); + node = get_class_cache_entry_value(tclass); if (av && node) for (i = 0; i<MAXVECTORS; i++) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ew...@us...> - 2007-06-11 16:59:47
|
Revision: 2472 http://svn.sourceforge.net/selinux/?rev=2472&view=rev Author: ewalsh Date: 2007-06-11 09:59:43 -0700 (Mon, 11 Jun 2007) Log Message: ----------- Author: Eamon Walsh Email: ew...@ty... Subject: libselinux: class and permission mapping support (try 3) Date: Fri, 08 Jun 2007 13:28:49 -0400 This patch makes avc_reset() exit properly if the AVC was not initialized. Signed-off-by: Eamon Walsh <ew...@ty...> Acked-by: Stephen Smalley <sd...@ty...> Modified Paths: -------------- trunk/libselinux/src/avc.c trunk/libselinux/src/avc_internal.c trunk/libselinux/src/avc_internal.h Modified: trunk/libselinux/src/avc.c =================================================================== --- trunk/libselinux/src/avc.c 2007-06-11 16:59:08 UTC (rev 2471) +++ trunk/libselinux/src/avc.c 2007-06-11 16:59:43 UTC (rev 2472) @@ -225,6 +225,7 @@ avc_netlink_thread = avc_create_thread(&avc_netlink_loop); avc_netlink_trouble = 0; } + avc_running = 1; out: return rc; } @@ -534,6 +535,9 @@ struct avc_node *node, *tmp; errno = 0; + if (!avc_running) + return 0; + avc_get_lock(avc_lock); for (i = 0; i < AVC_CACHE_SLOTS; i++) { @@ -609,6 +613,7 @@ avc_free_lock(avc_lock); avc_free_lock(avc_log_lock); avc_free(avc_audit_buf); + avc_running = 0; } /* ratelimit stuff put aside for now --EFW */ Modified: trunk/libselinux/src/avc_internal.c =================================================================== --- trunk/libselinux/src/avc_internal.c 2007-06-11 16:59:08 UTC (rev 2471) +++ trunk/libselinux/src/avc_internal.c 2007-06-11 16:59:43 UTC (rev 2472) @@ -44,6 +44,7 @@ /* message prefix string and avc enforcing mode */ char avc_prefix[AVC_PREFIX_SIZE] = "uavc"; +int avc_running = 0; int avc_enforcing = 1; int avc_netlink_trouble = 0; Modified: trunk/libselinux/src/avc_internal.h =================================================================== --- trunk/libselinux/src/avc_internal.h 2007-06-11 16:59:08 UTC (rev 2471) +++ trunk/libselinux/src/avc_internal.h 2007-06-11 16:59:43 UTC (rev 2472) @@ -71,6 +71,7 @@ /* message prefix and enforcing mode*/ #define AVC_PREFIX_SIZE 16 extern char avc_prefix[AVC_PREFIX_SIZE] hidden; +extern int avc_running hidden; extern int avc_enforcing hidden; /* user-supplied callback interface for avc */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ew...@us...> - 2007-06-11 17:01:04
|
Revision: 2473 http://svn.sourceforge.net/selinux/?rev=2473&view=rev Author: ewalsh Date: 2007-06-11 10:00:58 -0700 (Mon, 11 Jun 2007) Log Message: ----------- Author: Eamon Walsh Email: ew...@ty... Subject: libselinux: class and permission mapping support (try 3) Date: Fri, 08 Jun 2007 13:30:25 -0400 This patch includes the internal map and unmap functions and the changes to the selinuxfs interfaces to make it work. Signed-off-by: Eamon Walsh <ew...@ty...> Acked-by: Stephen Smalley <sd...@ty...> Modified Paths: -------------- trunk/libselinux/src/compute_av.c trunk/libselinux/src/compute_create.c trunk/libselinux/src/compute_member.c trunk/libselinux/src/compute_relabel.c trunk/libselinux/src/stringrep.c Added Paths: ----------- trunk/libselinux/src/mapping.h Modified: trunk/libselinux/src/compute_av.c =================================================================== --- trunk/libselinux/src/compute_av.c 2007-06-11 16:59:43 UTC (rev 2472) +++ trunk/libselinux/src/compute_av.c 2007-06-11 17:00:58 UTC (rev 2473) @@ -5,9 +5,10 @@ #include <stdio.h> #include <errno.h> #include <string.h> +#include <limits.h> #include "selinux_internal.h" #include "policy.h" -#include <limits.h> +#include "mapping.h" int security_compute_av_raw(security_context_t scon, security_context_t tcon, @@ -36,7 +37,8 @@ goto out; } - snprintf(buf, len, "%s %s %hu %x", scon, tcon, tclass, requested); + snprintf(buf, len, "%s %s %hu %x", scon, tcon, + unmap_class(tclass), unmap_perm(tclass, requested)); ret = write(fd, buf, strlen(buf)); if (ret < 0) @@ -54,6 +56,8 @@ goto out2; } + map_decision(tclass, avd); + ret = 0; out2: free(buf); Modified: trunk/libselinux/src/compute_create.c =================================================================== --- trunk/libselinux/src/compute_create.c 2007-06-11 16:59:43 UTC (rev 2472) +++ trunk/libselinux/src/compute_create.c 2007-06-11 17:00:58 UTC (rev 2473) @@ -5,9 +5,10 @@ #include <stdio.h> #include <errno.h> #include <string.h> +#include <limits.h> #include "selinux_internal.h" #include "policy.h" -#include <limits.h> +#include "mapping.h" int security_compute_create_raw(security_context_t scon, security_context_t tcon, @@ -35,7 +36,7 @@ ret = -1; goto out; } - snprintf(buf, size, "%s %s %hu", scon, tcon, tclass); + snprintf(buf, size, "%s %s %hu", scon, tcon, unmap_class(tclass)); ret = write(fd, buf, strlen(buf)); if (ret < 0) Modified: trunk/libselinux/src/compute_member.c =================================================================== --- trunk/libselinux/src/compute_member.c 2007-06-11 16:59:43 UTC (rev 2472) +++ trunk/libselinux/src/compute_member.c 2007-06-11 17:00:58 UTC (rev 2473) @@ -5,9 +5,10 @@ #include <stdio.h> #include <errno.h> #include <string.h> +#include <limits.h> #include "selinux_internal.h" #include "policy.h" -#include <limits.h> +#include "mapping.h" int security_compute_member_raw(security_context_t scon, security_context_t tcon, @@ -35,7 +36,7 @@ ret = -1; goto out; } - snprintf(buf, size, "%s %s %hu", scon, tcon, tclass); + snprintf(buf, size, "%s %s %hu", scon, tcon, unmap_class(tclass)); ret = write(fd, buf, strlen(buf)); if (ret < 0) Modified: trunk/libselinux/src/compute_relabel.c =================================================================== --- trunk/libselinux/src/compute_relabel.c 2007-06-11 16:59:43 UTC (rev 2472) +++ trunk/libselinux/src/compute_relabel.c 2007-06-11 17:00:58 UTC (rev 2473) @@ -5,9 +5,10 @@ #include <stdio.h> #include <errno.h> #include <string.h> +#include <limits.h> #include "selinux_internal.h" #include "policy.h" -#include <limits.h> +#include "mapping.h" int security_compute_relabel_raw(security_context_t scon, security_context_t tcon, @@ -35,7 +36,7 @@ ret = -1; goto out; } - snprintf(buf, size, "%s %s %hu", scon, tcon, tclass); + snprintf(buf, size, "%s %s %hu", scon, tcon, unmap_class(tclass)); ret = write(fd, buf, strlen(buf)); if (ret < 0) Added: trunk/libselinux/src/mapping.h =================================================================== --- trunk/libselinux/src/mapping.h (rev 0) +++ trunk/libselinux/src/mapping.h 2007-06-11 17:00:58 UTC (rev 2473) @@ -0,0 +1,34 @@ +/* + * This file describes the class and permission mappings used to + * hide the kernel numbers from userspace by allowing userspace object + * managers to specify a list of classes and permissions. + */ +#ifndef _SELINUX_MAPPING_H_ +#define _SELINUX_MAPPING_H_ + +#include <selinux/selinux.h> + +/* + * Get real, kernel values from mapped values + */ + +extern security_class_t +unmap_class(security_class_t tclass); + +extern access_vector_t +unmap_perm(security_class_t tclass, access_vector_t tperm); + +/* + * Get mapped values from real, kernel values + */ + +extern security_class_t +map_class(security_class_t kclass); + +extern access_vector_t +map_perm(security_class_t tclass, access_vector_t kperm); + +extern void +map_decision(security_class_t tclass, struct av_decision *avd); + +#endif /* _SELINUX_MAPPING_H_ */ Modified: trunk/libselinux/src/stringrep.c =================================================================== --- trunk/libselinux/src/stringrep.c 2007-06-11 16:59:43 UTC (rev 2472) +++ trunk/libselinux/src/stringrep.c 2007-06-11 17:00:58 UTC (rev 2473) @@ -17,6 +17,7 @@ #include <selinux/av_permissions.h> #include "selinux_internal.h" #include "policy.h" +#include "mapping.h" #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) @@ -315,12 +316,12 @@ if (isdigit(s[0])) { val = atoi(s); if (val > 0 && val < NCLASSES) - return val; + return map_class(val); } else { for (val = 0; val < NCLASSES; val++) { if (strcmp(s, (class_to_string_data.str + class_to_string[val])) == 0) - return val; + return map_class(val); } } @@ -333,9 +334,10 @@ const uint16_t *common_pts_idx = 0; access_vector_t perm, common_base = 0; unsigned int i; + security_class_t kclass = unmap_class(tclass); for (i = 0; i < ARRAY_SIZE(av_inherit); i++) { - if (av_inherit[i].tclass == tclass) { + if (av_inherit[i].tclass == kclass) { common_pts_idx = &common_perm_to_string.data[av_inherit[i]. common_pts_idx]; @@ -350,16 +352,16 @@ if (strcmp (s, common_perm_to_string_data.str + common_pts_idx[i]) == 0) - return perm; + return map_perm(tclass, perm); perm <<= 1; i++; } for (i = 0; i < NVECTORS; i++) { - if ((av_perm_to_string[i].tclass == tclass) && + if ((av_perm_to_string[i].tclass == kclass) && (strcmp(s, (av_perm_to_string_data.str + av_perm_to_string[i].nameidx)) == 0)) - return av_perm_to_string[i].value; + return map_perm(tclass, av_perm_to_string[i].value); } errno = EINVAL; @@ -368,6 +370,8 @@ static const char *security_class_to_string_compat(security_class_t tclass) { + tclass = unmap_class(tclass); + if (tclass > 0 && tclass < NCLASSES) return class_to_string_data.str + class_to_string[tclass]; @@ -382,6 +386,9 @@ access_vector_t common_base = 0; unsigned int i; + av = unmap_perm(tclass, av); + tclass = unmap_class(tclass); + if (!av) return NULL; @@ -432,22 +439,23 @@ } } - return node->value; + return map_class(node->value); } access_vector_t string_to_av_perm(security_class_t tclass, const char *s) { struct discover_class_node *node; + security_class_t kclass = unmap_class(tclass); if (obj_class_compat) return string_to_av_perm_compat(tclass,s); - node = get_class_cache_entry_value(tclass); + node = get_class_cache_entry_value(kclass); if (node != NULL) { size_t i; for (i=0; i<MAXVECTORS && node->perms[i] != NULL; i++) if (strcmp(node->perms[i],s) == 0) - return (1<<i); + return map_perm(tclass, 1<<i); } errno = EINVAL; @@ -461,6 +469,7 @@ if (obj_class_compat) return security_class_to_string_compat(tclass); + tclass = unmap_class(tclass); node = get_class_cache_entry_value(tclass); if (node == NULL) { errno = EINVAL; @@ -478,6 +487,8 @@ if (obj_class_compat) return security_av_perm_to_string_compat(tclass,av); + av = unmap_perm(tclass, av); + tclass = unmap_class(tclass); node = get_class_cache_entry_value(tclass); if (av && node) for (i = 0; i<MAXVECTORS; i++) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2007-06-22 19:36:08
|
Revision: 2489 http://svn.sourceforge.net/selinux/?rev=2489&view=rev Author: ssmalley Date: 2007-06-22 12:36:04 -0700 (Fri, 22 Jun 2007) Log Message: ----------- Author: James Athey Email: ja...@tr... Subject: libselinux: refactored SWIG bindings Date: Tue, 19 Jun 2007 15:51:11 -0400 The previous patch did not include the changes to the Makefile or the typo fix to fsetfilecon.c. Here's an updated patch. Acked-by: Stephen Smalley <sd...@ty...> Modified Paths: -------------- trunk/libselinux/src/Makefile trunk/libselinux/src/fsetfilecon.c trunk/libselinux/src/selinux.py trunk/libselinux/src/selinuxswig.i trunk/libselinux/src/selinuxswig_wrap.c Added Paths: ----------- trunk/libselinux/src/selinuxswig_python.i Modified: trunk/libselinux/src/Makefile =================================================================== --- trunk/libselinux/src/Makefile 2007-06-20 19:20:47 UTC (rev 2488) +++ trunk/libselinux/src/Makefile 2007-06-22 19:36:04 UTC (rev 2489) @@ -12,7 +12,7 @@ LIBA=libselinux.a TARGET=libselinux.so -SWIGIF= selinuxswig.i +SWIGIF= selinuxswig_python.i SWIGCOUT= selinuxswig_wrap.c SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT)) SWIGSO=_selinux.so Modified: trunk/libselinux/src/fsetfilecon.c =================================================================== --- trunk/libselinux/src/fsetfilecon.c 2007-06-20 19:20:47 UTC (rev 2488) +++ trunk/libselinux/src/fsetfilecon.c 2007-06-22 19:36:04 UTC (rev 2489) @@ -13,7 +13,7 @@ 0); } -hidden_def(setfilecon_raw) +hidden_def(fsetfilecon_raw) int fsetfilecon(int fd, security_context_t context) { Modified: trunk/libselinux/src/selinux.py =================================================================== --- trunk/libselinux/src/selinux.py 2007-06-20 19:20:47 UTC (rev 2488) +++ trunk/libselinux/src/selinux.py 2007-06-22 19:36:04 UTC (rev 2489) @@ -48,61 +48,224 @@ del types -SELINUX_DEFAULTUSER = _selinux.SELINUX_DEFAULTUSER -get_ordered_context_list = _selinux.get_ordered_context_list -get_ordered_context_list_with_level = _selinux.get_ordered_context_list_with_level -get_default_context = _selinux.get_default_context -get_default_context_with_level = _selinux.get_default_context_with_level -get_default_context_with_role = _selinux.get_default_context_with_role -get_default_context_with_rolelevel = _selinux.get_default_context_with_rolelevel -query_user_context = _selinux.query_user_context -manual_user_enter_context = _selinux.manual_user_enter_context is_selinux_enabled = _selinux.is_selinux_enabled is_selinux_mls_enabled = _selinux.is_selinux_mls_enabled -freecon = _selinux.freecon -freeconary = _selinux.freeconary getcon = _selinux.getcon +getcon_raw = _selinux.getcon_raw setcon = _selinux.setcon +setcon_raw = _selinux.setcon_raw getpidcon = _selinux.getpidcon +getpidcon_raw = _selinux.getpidcon_raw getprevcon = _selinux.getprevcon +getprevcon_raw = _selinux.getprevcon_raw getexeccon = _selinux.getexeccon +getexeccon_raw = _selinux.getexeccon_raw setexeccon = _selinux.setexeccon +setexeccon_raw = _selinux.setexeccon_raw getfscreatecon = _selinux.getfscreatecon +getfscreatecon_raw = _selinux.getfscreatecon_raw setfscreatecon = _selinux.setfscreatecon +setfscreatecon_raw = _selinux.setfscreatecon_raw getkeycreatecon = _selinux.getkeycreatecon +getkeycreatecon_raw = _selinux.getkeycreatecon_raw setkeycreatecon = _selinux.setkeycreatecon +setkeycreatecon_raw = _selinux.setkeycreatecon_raw getsockcreatecon = _selinux.getsockcreatecon +getsockcreatecon_raw = _selinux.getsockcreatecon_raw setsockcreatecon = _selinux.setsockcreatecon +setsockcreatecon_raw = _selinux.setsockcreatecon_raw getfilecon = _selinux.getfilecon +getfilecon_raw = _selinux.getfilecon_raw lgetfilecon = _selinux.lgetfilecon +lgetfilecon_raw = _selinux.lgetfilecon_raw fgetfilecon = _selinux.fgetfilecon +fgetfilecon_raw = _selinux.fgetfilecon_raw setfilecon = _selinux.setfilecon +setfilecon_raw = _selinux.setfilecon_raw lsetfilecon = _selinux.lsetfilecon +lsetfilecon_raw = _selinux.lsetfilecon_raw fsetfilecon = _selinux.fsetfilecon +fsetfilecon_raw = _selinux.fsetfilecon_raw getpeercon = _selinux.getpeercon +getpeercon_raw = _selinux.getpeercon_raw +class av_decision(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, av_decision, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, av_decision, name) + __repr__ = _swig_repr + __swig_setmethods__["allowed"] = _selinux.av_decision_allowed_set + __swig_getmethods__["allowed"] = _selinux.av_decision_allowed_get + if _newclass:allowed = _swig_property(_selinux.av_decision_allowed_get, _selinux.av_decision_allowed_set) + __swig_setmethods__["decided"] = _selinux.av_decision_decided_set + __swig_getmethods__["decided"] = _selinux.av_decision_decided_get + if _newclass:decided = _swig_property(_selinux.av_decision_decided_get, _selinux.av_decision_decided_set) + __swig_setmethods__["auditallow"] = _selinux.av_decision_auditallow_set + __swig_getmethods__["auditallow"] = _selinux.av_decision_auditallow_get + if _newclass:auditallow = _swig_property(_selinux.av_decision_auditallow_get, _selinux.av_decision_auditallow_set) + __swig_setmethods__["auditdeny"] = _selinux.av_decision_auditdeny_set + __swig_getmethods__["auditdeny"] = _selinux.av_decision_auditdeny_get + if _newclass:auditdeny = _swig_property(_selinux.av_decision_auditdeny_get, _selinux.av_decision_auditdeny_set) + __swig_setmethods__["seqno"] = _selinux.av_decision_seqno_set + __swig_getmethods__["seqno"] = _selinux.av_decision_seqno_get + if _newclass:seqno = _swig_property(_selinux.av_decision_seqno_get, _selinux.av_decision_seqno_set) + def __init__(self, *args): + this = _selinux.new_av_decision(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _selinux.delete_av_decision + __del__ = lambda self : None; +av_decision_swigregister = _selinux.av_decision_swigregister +av_decision_swigregister(av_decision) + +class selinux_opt(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, selinux_opt, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, selinux_opt, name) + __repr__ = _swig_repr + __swig_setmethods__["type"] = _selinux.selinux_opt_type_set + __swig_getmethods__["type"] = _selinux.selinux_opt_type_get + if _newclass:type = _swig_property(_selinux.selinux_opt_type_get, _selinux.selinux_opt_type_set) + __swig_setmethods__["value"] = _selinux.selinux_opt_value_set + __swig_getmethods__["value"] = _selinux.selinux_opt_value_get + if _newclass:value = _swig_property(_selinux.selinux_opt_value_get, _selinux.selinux_opt_value_set) + def __init__(self, *args): + this = _selinux.new_selinux_opt(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _selinux.delete_selinux_opt + __del__ = lambda self : None; +selinux_opt_swigregister = _selinux.selinux_opt_swigregister +selinux_opt_swigregister(selinux_opt) + +class selinux_callback(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, selinux_callback, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, selinux_callback, name) + __repr__ = _swig_repr + __swig_setmethods__["func_log"] = _selinux.selinux_callback_func_log_set + __swig_getmethods__["func_log"] = _selinux.selinux_callback_func_log_get + if _newclass:func_log = _swig_property(_selinux.selinux_callback_func_log_get, _selinux.selinux_callback_func_log_set) + __swig_setmethods__["func_audit"] = _selinux.selinux_callback_func_audit_set + __swig_getmethods__["func_audit"] = _selinux.selinux_callback_func_audit_get + if _newclass:func_audit = _swig_property(_selinux.selinux_callback_func_audit_get, _selinux.selinux_callback_func_audit_set) + __swig_setmethods__["func_validate"] = _selinux.selinux_callback_func_validate_set + __swig_getmethods__["func_validate"] = _selinux.selinux_callback_func_validate_get + if _newclass:func_validate = _swig_property(_selinux.selinux_callback_func_validate_get, _selinux.selinux_callback_func_validate_set) + def __init__(self, *args): + this = _selinux.new_selinux_callback(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _selinux.delete_selinux_callback + __del__ = lambda self : None; +selinux_callback_swigregister = _selinux.selinux_callback_swigregister +selinux_callback_swigregister(selinux_callback) + +SELINUX_CB_LOG = _selinux.SELINUX_CB_LOG +SELINUX_CB_AUDIT = _selinux.SELINUX_CB_AUDIT +SELINUX_CB_VALIDATE = _selinux.SELINUX_CB_VALIDATE +selinux_set_callback = _selinux.selinux_set_callback +SELINUX_ERROR = _selinux.SELINUX_ERROR +SELINUX_WARNING = _selinux.SELINUX_WARNING +SELINUX_INFO = _selinux.SELINUX_INFO +SELINUX_AVC = _selinux.SELINUX_AVC +security_compute_av = _selinux.security_compute_av +security_compute_av_raw = _selinux.security_compute_av_raw +security_compute_create = _selinux.security_compute_create +security_compute_create_raw = _selinux.security_compute_create_raw +security_compute_relabel = _selinux.security_compute_relabel +security_compute_relabel_raw = _selinux.security_compute_relabel_raw +security_compute_member = _selinux.security_compute_member +security_compute_member_raw = _selinux.security_compute_member_raw +security_compute_user = _selinux.security_compute_user +security_compute_user_raw = _selinux.security_compute_user_raw +security_load_policy = _selinux.security_load_policy +security_get_initial_context = _selinux.security_get_initial_context +security_get_initial_context_raw = _selinux.security_get_initial_context_raw selinux_mkload_policy = _selinux.selinux_mkload_policy selinux_init_load_policy = _selinux.selinux_init_load_policy +class SELboolean(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, SELboolean, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, SELboolean, name) + __repr__ = _swig_repr + __swig_setmethods__["name"] = _selinux.SELboolean_name_set + __swig_getmethods__["name"] = _selinux.SELboolean_name_get + if _newclass:name = _swig_property(_selinux.SELboolean_name_get, _selinux.SELboolean_name_set) + __swig_setmethods__["value"] = _selinux.SELboolean_value_set + __swig_getmethods__["value"] = _selinux.SELboolean_value_get + if _newclass:value = _swig_property(_selinux.SELboolean_value_get, _selinux.SELboolean_value_set) + def __init__(self, *args): + this = _selinux.new_SELboolean(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _selinux.delete_SELboolean + __del__ = lambda self : None; +SELboolean_swigregister = _selinux.SELboolean_swigregister +SELboolean_swigregister(SELboolean) + security_set_boolean_list = _selinux.security_set_boolean_list security_load_booleans = _selinux.security_load_booleans security_check_context = _selinux.security_check_context +security_check_context_raw = _selinux.security_check_context_raw security_canonicalize_context = _selinux.security_canonicalize_context +security_canonicalize_context_raw = _selinux.security_canonicalize_context_raw security_getenforce = _selinux.security_getenforce security_setenforce = _selinux.security_setenforce +security_disable = _selinux.security_disable security_policyvers = _selinux.security_policyvers security_get_boolean_names = _selinux.security_get_boolean_names security_get_boolean_pending = _selinux.security_get_boolean_pending security_get_boolean_active = _selinux.security_get_boolean_active security_set_boolean = _selinux.security_set_boolean security_commit_booleans = _selinux.security_commit_booleans +class security_class_mapping(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, security_class_mapping, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, security_class_mapping, name) + __repr__ = _swig_repr + __swig_setmethods__["name"] = _selinux.security_class_mapping_name_set + __swig_getmethods__["name"] = _selinux.security_class_mapping_name_get + if _newclass:name = _swig_property(_selinux.security_class_mapping_name_get, _selinux.security_class_mapping_name_set) + __swig_setmethods__["perms"] = _selinux.security_class_mapping_perms_set + __swig_getmethods__["perms"] = _selinux.security_class_mapping_perms_get + if _newclass:perms = _swig_property(_selinux.security_class_mapping_perms_get, _selinux.security_class_mapping_perms_set) + def __init__(self, *args): + this = _selinux.new_security_class_mapping(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _selinux.delete_security_class_mapping + __del__ = lambda self : None; +security_class_mapping_swigregister = _selinux.security_class_mapping_swigregister +security_class_mapping_swigregister(security_class_mapping) + +selinux_set_mapping = _selinux.selinux_set_mapping +string_to_security_class = _selinux.string_to_security_class +security_class_to_string = _selinux.security_class_to_string +security_av_perm_to_string = _selinux.security_av_perm_to_string +string_to_av_perm = _selinux.string_to_av_perm +security_av_string = _selinux.security_av_string +print_access_vector = _selinux.print_access_vector MATCHPATHCON_BASEONLY = _selinux.MATCHPATHCON_BASEONLY MATCHPATHCON_NOTRANS = _selinux.MATCHPATHCON_NOTRANS +MATCHPATHCON_VALIDATE = _selinux.MATCHPATHCON_VALIDATE set_matchpathcon_flags = _selinux.set_matchpathcon_flags matchpathcon_init = _selinux.matchpathcon_init -matchpathcon = _selinux.matchpathcon matchpathcon_init_prefix = _selinux.matchpathcon_init_prefix matchpathcon_fini = _selinux.matchpathcon_fini +matchpathcon = _selinux.matchpathcon +matchpathcon_index = _selinux.matchpathcon_index +matchpathcon_filespec_add = _selinux.matchpathcon_filespec_add +matchpathcon_filespec_destroy = _selinux.matchpathcon_filespec_destroy +matchpathcon_filespec_eval = _selinux.matchpathcon_filespec_eval +matchpathcon_checkmatches = _selinux.matchpathcon_checkmatches matchmediacon = _selinux.matchmediacon selinux_getenforcemode = _selinux.selinux_getenforcemode +selinux_getpolicytype = _selinux.selinux_getpolicytype selinux_policy_root = _selinux.selinux_policy_root selinux_binary_policy_path = _selinux.selinux_binary_policy_path selinux_failsafe_context_path = _selinux.selinux_failsafe_context_path @@ -123,16 +286,28 @@ selinux_translations_path = _selinux.selinux_translations_path selinux_netfilter_context_path = _selinux.selinux_netfilter_context_path selinux_path = _selinux.selinux_path +selinux_check_passwd_access = _selinux.selinux_check_passwd_access +checkPasswdAccess = _selinux.checkPasswdAccess selinux_check_securetty_context = _selinux.selinux_check_securetty_context set_selinuxmnt = _selinux.set_selinuxmnt rpm_execcon = _selinux.rpm_execcon is_context_customizable = _selinux.is_context_customizable selinux_trans_to_raw_context = _selinux.selinux_trans_to_raw_context selinux_raw_to_trans_context = _selinux.selinux_raw_to_trans_context -selinux_getpolicytype = _selinux.selinux_getpolicytype getseuserbyname = _selinux.getseuserbyname selinux_file_context_cmp = _selinux.selinux_file_context_cmp selinux_file_context_verify = _selinux.selinux_file_context_verify selinux_lsetfilecon_default = _selinux.selinux_lsetfilecon_default +selinux_default_type_path = _selinux.selinux_default_type_path +get_default_type = _selinux.get_default_type +SELINUX_DEFAULTUSER = _selinux.SELINUX_DEFAULTUSER +get_ordered_context_list = _selinux.get_ordered_context_list +get_ordered_context_list_with_level = _selinux.get_ordered_context_list_with_level +get_default_context = _selinux.get_default_context +get_default_context_with_level = _selinux.get_default_context_with_level +get_default_context_with_role = _selinux.get_default_context_with_role +get_default_context_with_rolelevel = _selinux.get_default_context_with_rolelevel +query_user_context = _selinux.query_user_context +manual_user_enter_context = _selinux.manual_user_enter_context Modified: trunk/libselinux/src/selinuxswig.i =================================================================== --- trunk/libselinux/src/selinuxswig.i 2007-06-20 19:20:47 UTC (rev 2488) +++ trunk/libselinux/src/selinuxswig.i 2007-06-22 19:36:04 UTC (rev 2489) @@ -1,7 +1,9 @@ -/* Author: Dan Walsh +/* Authors: Dan Walsh + * James Athey * * Copyright (C) 2004-2005 Red Hat - * + * Copyright (C) 2007 Tresys Technology, LLC + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -17,170 +19,47 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - %module selinux %{ #include "selinux/selinux.h" - #include "selinux/get_context_list.h" %} -%apply int *OUTPUT { int * }; +%apply int *OUTPUT { int *enforce }; %apply int *OUTPUT { size_t * }; -%typemap(in, numinputs=0) security_context_t *(security_context_t temp=NULL) { - $1 = &temp; -} -%typemap(argout) security_context_t * (char *temp=NULL) { - if (*$1) - temp = *$1; - else - temp = ""; - $result = SWIG_Python_AppendOutput($result, PyString_FromString(temp)); -} +%typedef unsigned mode_t; -%typemap(in) security_context_t { - $1 = (security_context_t)PyString_AsString($input); +%typemap(in, numinputs=0) (char ***names, int *len) (char **temp1, int temp2) { + $1 = &temp1; + $2 = &temp2; } -%typedef unsigned mode_t; - -%include "../include/selinux/get_context_list.h" - -extern int is_selinux_enabled(void); -extern int is_selinux_mls_enabled(void); -extern void freecon(security_context_t con); -extern void freeconary(security_context_t * con); -extern int getcon(security_context_t *con); -extern int setcon(security_context_t con); -extern int getpidcon(int pid, security_context_t *con); -extern int getprevcon(security_context_t *con); -extern int getexeccon(security_context_t *con); -extern int setexeccon(security_context_t con); -extern int getfscreatecon(security_context_t *con); -extern int setfscreatecon(security_context_t context); -extern int getkeycreatecon(security_context_t *con); -extern int setkeycreatecon(security_context_t context); -extern int getsockcreatecon(security_context_t *con); -extern int setsockcreatecon(security_context_t context); -extern int getfilecon(const char *path, security_context_t *con); -extern int lgetfilecon(const char *path, security_context_t *con); -extern int fgetfilecon(int fd, security_context_t *con); -extern int setfilecon(const char *path, security_context_t con); -extern int lsetfilecon(const char *path, security_context_t con); -extern int fsetfilecon(int fd, security_context_t con); -extern int getpeercon(int fd, security_context_t *con); -extern int selinux_mkload_policy(int preservebools); -extern int selinux_init_load_policy(int *enforce); -extern int security_set_boolean_list(size_t boolcnt, - SELboolean *boollist, - int permanent); -extern int security_load_booleans(char *path); -extern int security_check_context(security_context_t con); -extern int security_canonicalize_context(security_context_t con, - security_context_t *canoncon); -extern int security_getenforce(void); -extern int security_setenforce(int value); -extern int security_policyvers(void); -extern int security_get_boolean_names(char ***names, int *len); -extern int security_get_boolean_pending(const char *name); -extern int security_get_boolean_active(const char *name); -extern int security_set_boolean(const char *name, int value); -extern int security_commit_booleans(void); - -/* Set flags controlling operation of matchpathcon_init or matchpathcon. */ -#define MATCHPATHCON_BASEONLY 1 /* Only process the base file_contexts file. */ -#define MATCHPATHCON_NOTRANS 2 /* Do not perform any context translation. */ -extern void set_matchpathcon_flags(unsigned int flags); -extern int matchpathcon_init(const char *path); -extern int matchpathcon(const char *path, - mode_t mode, - security_context_t *con); - -extern int matchpathcon_init_prefix(const char *path, - const char *prefix); -extern void matchpathcon_fini(void); - - -extern int matchmediacon(const char *media, - security_context_t *con); - -extern int selinux_getenforcemode(int *enforce); -extern const char *selinux_policy_root(void); -extern const char *selinux_binary_policy_path(void); -extern const char *selinux_failsafe_context_path(void); -extern const char *selinux_removable_context_path(void); -extern const char *selinux_default_context_path(void); -extern const char *selinux_user_contexts_path(void); -extern const char *selinux_file_context_path(void); -extern const char *selinux_file_context_homedir_path(void); -extern const char *selinux_file_context_local_path(void); -extern const char *selinux_homedir_context_path(void); -extern const char *selinux_media_context_path(void); -extern const char *selinux_contexts_path(void); -extern const char *selinux_securetty_types_path(void); -extern const char *selinux_booleans_path(void); -extern const char *selinux_customizable_types_path(void); -extern const char *selinux_users_path(void); -extern const char *selinux_usersconf_path(void); -extern const char *selinux_translations_path(void); -extern const char *selinux_netfilter_context_path(void); -extern const char *selinux_path(void); -#extern int selinux_check_passwd_access(access_vector_t requested); -#extern int checkPasswdAccess(access_vector_t requested); - -extern int selinux_check_securetty_context(security_context_t tty_context); -void set_selinuxmnt(char *mnt); - -#ifdef SWIGpython -// This tells SWIG to treat char ** as a special case -%typemap(in) char ** { - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $1 = (char **) malloc((size+1)*sizeof(char *)); - if ($1 == NULL) { - PyErr_SetString(PyExc_MemoryError,"Out of memory"); - return NULL; - } - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyString_Check(o)) - $1[i] = PyString_AsString(PyList_GetItem($input,i)); - else { - PyErr_SetString(PyExc_TypeError,"list must contain strings"); - free($1); - return NULL; - } - } - $1[i] = 0; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } +%typemap(freearg) (char ***names, int *len) { + int i; + if (*$1) { + for (i = 0; i < *$2; i++) { + free((*$1)[i]); + } + free(*$1); + } } -#endif -extern int rpm_execcon(unsigned int verified, - const char *filename, - char **, char **); - -extern int is_context_customizable (security_context_t scontext); - -extern int selinux_trans_to_raw_context(char *trans, - security_context_t *rawp); -extern int selinux_raw_to_trans_context(char *raw, - security_context_t *transp); - -%typemap(in, numinputs=0) char **(char *temp=NULL) { +%typemap(in, numinputs=0) (security_context_t **) (security_context_t *temp) { $1 = &temp; } -%typemap(argout) char ** { - $result = SWIG_Python_AppendOutput($result, PyString_FromString(*$1)); +%typemap(freearg) (security_context_t **) { + if (*$1) freeconary(*$1); } -extern int selinux_getpolicytype(char **enforce); -extern int getseuserbyname(const char *linuxuser, char **seuser, char **level); -int selinux_file_context_cmp(const security_context_t a, const security_context_t b); -int selinux_file_context_verify(const char *path, mode_t mode); -int selinux_lsetfilecon_default(const char *path); +/* Ignore functions that don't make sense when wrapped */ +%ignore freecon; +%ignore freeconary; + +/* Ignore functions that take a function pointer as an argument */ +%ignore set_matchpathcon_printf; +%ignore set_matchpathcon_invalidcon; +%ignore set_matchpathcon_canoncon; + +%include "../include/selinux/selinux.h" +%include "../include/selinux/get_default_type.h" +%include "../include/selinux/get_context_list.h" Added: trunk/libselinux/src/selinuxswig_python.i =================================================================== --- trunk/libselinux/src/selinuxswig_python.i (rev 0) +++ trunk/libselinux/src/selinuxswig_python.i 2007-06-22 19:36:04 UTC (rev 2489) @@ -0,0 +1,101 @@ +/* Author: James Athey + * + * Copyright (C) 2007 Tresys Technology, LLC + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +%module selinux +%{ + #include "selinux/selinux.h" +%} + +/* security_get_boolean_names() typemap */ +%typemap(argout) (char ***names, int *len) { + PyObject* list = PyList_New(*$2); + int i; + for (i = 0; i < *$2; i++) { + PyList_SetItem(list, i, PyString_FromString((*$1)[i])); + } + $result = SWIG_Python_AppendOutput($result, list); +} + +/* Makes security_compute_user() return a Python list of contexts */ +%typemap(argout) (security_context_t **con) { + PyObject* plist; + int i, len = 0; + + if (*$1) { + while((*$1)[len]) + len++; + plist = PyList_New(len); + for (i = 0; i < len; i++) { + PyList_SetItem(plist, i, PyString_FromString((*$1)[i])); + } + } else { + plist = PyList_New(0); + } + + $result = SWIG_Python_AppendOutput($result, plist); +} + +/* Makes functions in get_context_list.h return a Python list of contexts */ +%typemap(argout) (security_context_t **list) { + PyObject* plist; + int i; + + if (*$1) { + plist = PyList_New(result); + for (i = 0; i < result; i++) { + PyList_SetItem(plist, i, PyString_FromString((*$1)[i])); + } + } else { + plist = PyList_New(0); + } + /* Only return the Python list, don't need to return the length anymore */ + $result = plist; +} + +%typemap(in,noblock=1,numinputs=0) security_context_t * (security_context_t temp = 0) { + $1 = &temp; +} +%typemap(freearg,match="in") security_context_t * ""; +%typemap(argout,noblock=1) security_context_t * { + if (*$1) { + %append_output(SWIG_FromCharPtr(*$1)); + freecon(*$1); + } + else { + Py_INCREF(Py_None); + %append_output(Py_None); + } +} + +%typemap(in,noblock=1,numinputs=0) char ** (char * temp = 0) { + $1 = &temp; +} +%typemap(freearg,match="in") char ** ""; +%typemap(argout,noblock=1) char ** { + if (*$1) { + %append_output(SWIG_FromCharPtr(*$1)); + free(*$1); + } + else { + Py_INCREF(Py_None); + %append_output(Py_None); + } +} + +%include "selinuxswig.i" Modified: trunk/libselinux/src/selinuxswig_wrap.c =================================================================== --- trunk/libselinux/src/selinuxswig_wrap.c 2007-06-20 19:20:47 UTC (rev 2488) +++ trunk/libselinux/src/selinuxswig_wrap.c 2007-06-22 19:36:04 UTC (rev 2489) @@ -2449,15 +2449,23 @@ /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_SELboolean swig_types[0] -#define SWIGTYPE_p_char swig_types[1] -#define SWIGTYPE_p_int swig_types[2] -#define SWIGTYPE_p_p_char swig_types[3] -#define SWIGTYPE_p_p_p_char swig_types[4] -#define SWIGTYPE_p_p_security_context_t swig_types[5] -#define SWIGTYPE_p_security_context_t swig_types[6] -#define SWIGTYPE_p_unsigned_int swig_types[7] -static swig_type_info *swig_types[9]; -static swig_module_info swig_module = {swig_types, 8, 0, 0, 0, 0}; +#define SWIGTYPE_p_av_decision swig_types[1] +#define SWIGTYPE_p_char swig_types[2] +#define SWIGTYPE_p_f_int_p_q_const__char_v_______int swig_types[3] +#define SWIGTYPE_p_f_p_p_char__int swig_types[4] +#define SWIGTYPE_p_f_p_void_unsigned_short_p_char_size_t__int swig_types[5] +#define SWIGTYPE_p_ino_t swig_types[6] +#define SWIGTYPE_p_int swig_types[7] +#define SWIGTYPE_p_p_char swig_types[8] +#define SWIGTYPE_p_p_p_char swig_types[9] +#define SWIGTYPE_p_pid_t swig_types[10] +#define SWIGTYPE_p_security_class_mapping swig_types[11] +#define SWIGTYPE_p_selinux_callback swig_types[12] +#define SWIGTYPE_p_selinux_opt swig_types[13] +#define SWIGTYPE_p_unsigned_int swig_types[14] +#define SWIGTYPE_p_unsigned_short swig_types[15] +static swig_type_info *swig_types[17]; +static swig_module_info swig_module = {swig_types, 16, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -2485,9 +2493,21 @@ #include "selinux/selinux.h" - #include "selinux/get_context_list.h" + #include "selinux/selinux.h" + + + #define SWIG_From_long PyInt_FromLong + + +SWIGINTERNINLINE PyObject * +SWIG_From_int (int value) +{ + return SWIG_From_long (value); +} + + SWIGINTERN swig_type_info* SWIG_pchar_descriptor(void) { @@ -2501,30 +2521,6 @@ } -SWIGINTERNINLINE PyObject * -SWIG_FromCharPtrAndSize(const char* carray, size_t size) -{ - if (carray) { - if (size > INT_MAX) { - swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); - return pchar_descriptor ? - SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); - } else { - return PyString_FromStringAndSize(carray, (int)(size)); - } - } else { - return SWIG_Py_Void(); - } -} - - -SWIGINTERNINLINE PyObject * -SWIG_FromCharPtr(const char *cptr) -{ - return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); -} - - SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { @@ -2580,16 +2576,6 @@ - #define SWIG_From_long PyInt_FromLong - - -SWIGINTERNINLINE PyObject * -SWIG_From_int (int value) -{ - return SWIG_From_long (value); -} - - #include <limits.h> #ifndef LLONG_MIN # define LLONG_MIN LONG_LONG_MIN @@ -2781,65 +2767,411 @@ } -SWIGINTERNINLINE int -SWIG_AsVal_size_t (PyObject * obj, size_t *val) +SWIGINTERN int +SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) { unsigned long v; - int res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); - if (SWIG_IsOK(res) && val) *val = (size_t)(v); + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v > UINT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (unsigned int)(v); + } + } return res; } +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long (unsigned long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); +} + + +SWIGINTERNINLINE PyObject * +SWIG_From_unsigned_SS_int (unsigned int value) +{ + return SWIG_From_unsigned_SS_long (value); +} + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); + } else { + return PyString_FromStringAndSize(carray, (int)(size)); + } + } else { + return SWIG_Py_Void(); + } +} + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + + SWIGINTERN int -SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) +SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) { unsigned long v; int res = SWIG_AsVal_unsigned_SS_long (obj, &v); if (SWIG_IsOK(res)) { - if ((v > UINT_MAX)) { + if ((v > USHRT_MAX)) { return SWIG_OverflowError; } else { - if (val) *val = (unsigned int)(v); + if (val) *val = (unsigned short)(v); } } return res; } + +SWIGINTERNINLINE int +SWIG_AsVal_size_t (PyObject * obj, size_t *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = (size_t)(v); + return res; +} + + +SWIGINTERNINLINE PyObject * +SWIG_From_unsigned_SS_short (unsigned short value) +{ + return SWIG_From_unsigned_SS_long (value); +} + #ifdef __cplusplus extern "C" { #endif -SWIGINTERN PyObject *_wrap_get_ordered_context_list(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_is_selinux_enabled(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - security_context_t arg2 ; - security_context_t **arg3 = (security_context_t **) 0 ; int result; + + if (!PyArg_ParseTuple(args,(char *)":is_selinux_enabled")) SWIG_fail; + result = (int)is_selinux_enabled(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_is_selinux_mls_enabled(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!PyArg_ParseTuple(args,(char *)":is_selinux_mls_enabled")) SWIG_fail; + result = (int)is_selinux_mls_enabled(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getcon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = 0 ; + + arg1 = &temp1; + if (!PyArg_ParseTuple(args,(char *)":getcon")) SWIG_fail; + result = (int)getcon(arg1); + resultobj = SWIG_From_int((int)(result)); + if (*arg1) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg1)); + freecon(*arg1); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getcon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = 0 ; + + arg1 = &temp1; + if (!PyArg_ParseTuple(args,(char *)":getcon_raw")) SWIG_fail; + result = (int)getcon_raw(arg1); + resultobj = SWIG_From_int((int)(result)); + if (*arg1) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg1)); + freecon(*arg1); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_setcon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 = (security_context_t) 0 ; + int result; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OOO:get_ordered_context_list",&obj0,&obj1,&obj2)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"O:setcon",&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_ordered_context_list" "', argument " "1"" of type '" "char const *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "setcon" "', argument " "1"" of type '" "security_context_t""'"); } - arg1 = (char *)(buf1); + arg1 = (security_context_t)(buf1); + result = (int)setcon(arg1); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_setcon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 = (security_context_t) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:setcon_raw",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "setcon_raw" "', argument " "1"" of type '" "security_context_t""'"); + } + arg1 = (security_context_t)(buf1); + result = (int)setcon_raw(arg1); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getpidcon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + pid_t arg1 ; + security_context_t *arg2 = (security_context_t *) 0 ; + int result; + void *argp1 ; + int res1 = 0 ; + security_context_t temp2 = 0 ; + PyObject * obj0 = 0 ; + + arg2 = &temp2; + if (!PyArg_ParseTuple(args,(char *)"O:getpidcon",&obj0)) SWIG_fail; { - arg2 = (security_context_t)PyString_AsString(obj1); + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_pid_t, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "getpidcon" "', argument " "1"" of type '" "pid_t""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "getpidcon" "', argument " "1"" of type '" "pid_t""'"); + } else { + arg1 = *((pid_t *)(argp1)); + } } - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_p_security_context_t, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "get_ordered_context_list" "', argument " "3"" of type '" "security_context_t **""'"); + result = (int)getpidcon(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + if (*arg2) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); + freecon(*arg2); } - arg3 = (security_context_t **)(argp3); - result = (int)get_ordered_context_list((char const *)arg1,arg2,arg3); + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getpidcon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + pid_t arg1 ; + security_context_t *arg2 = (security_context_t *) 0 ; + int result; + void *argp1 ; + int res1 = 0 ; + security_context_t temp2 = 0 ; + PyObject * obj0 = 0 ; + + arg2 = &temp2; + if (!PyArg_ParseTuple(args,(char *)"O:getpidcon_raw",&obj0)) SWIG_fail; + { + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_pid_t, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "getpidcon_raw" "', argument " "1"" of type '" "pid_t""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "getpidcon_raw" "', argument " "1"" of type '" "pid_t""'"); + } else { + arg1 = *((pid_t *)(argp1)); + } + } + result = (int)getpidcon_raw(arg1,arg2); resultobj = SWIG_From_int((int)(result)); + if (*arg2) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); + freecon(*arg2); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getprevcon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = 0 ; + + arg1 = &temp1; + if (!PyArg_ParseTuple(args,(char *)":getprevcon")) SWIG_fail; + result = (int)getprevcon(arg1); + resultobj = SWIG_From_int((int)(result)); + if (*arg1) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg1)); + freecon(*arg1); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getprevcon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = 0 ; + + arg1 = &temp1; + if (!PyArg_ParseTuple(args,(char *)":getprevcon_raw")) SWIG_fail; + result = (int)getprevcon_raw(arg1); + resultobj = SWIG_From_int((int)(result)); + if (*arg1) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg1)); + freecon(*arg1); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getexeccon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = 0 ; + + arg1 = &temp1; + if (!PyArg_ParseTuple(args,(char *)":getexeccon")) SWIG_fail; + result = (int)getexeccon(arg1); + resultobj = SWIG_From_int((int)(result)); + if (*arg1) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg1)); + freecon(*arg1); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getexeccon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = 0 ; + + arg1 = &temp1; + if (!PyArg_ParseTuple(args,(char *)":getexeccon_raw")) SWIG_fail; + result = (int)getexeccon_raw(arg1); + resultobj = SWIG_From_int((int)(result)); + if (*arg1) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg1)); + freecon(*arg1); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_setexeccon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 = (security_context_t) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:setexeccon",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "setexeccon" "', argument " "1"" of type '" "security_context_t""'"); + } + arg1 = (security_context_t)(buf1); + result = (int)setexeccon(arg1); + resultobj = SWIG_From_int((int)(result)); if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); return resultobj; fail: @@ -2848,92 +3180,461 @@ } -SWIGINTERN PyObject *_wrap_get_ordered_context_list_with_level(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_setexeccon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; + security_context_t arg1 = (security_context_t) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:setexeccon_raw",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "setexeccon_raw" "', argument " "1"" of type '" "security_context_t""'"); + } + arg1 = (security_context_t)(buf1); + result = (int)setexeccon_raw(arg1); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getfscreatecon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = 0 ; + + arg1 = &temp1; + if (!PyArg_ParseTuple(args,(char *)":getfscreatecon")) SWIG_fail; + result = (int)getfscreatecon(arg1); + resultobj = SWIG_From_int((int)(result)); + if (*arg1) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg1)); + freecon(*arg1); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getfscreatecon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = 0 ; + + arg1 = &temp1; + if (!PyArg_ParseTuple(args,(char *)":getfscreatecon_raw")) SWIG_fail; + result = (int)getfscreatecon_raw(arg1); + resultobj = SWIG_From_int((int)(result)); + if (*arg1) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg1)); + freecon(*arg1); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_setfscreatecon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 = (security_context_t) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:setfscreatecon",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "setfscreatecon" "', argument " "1"" of type '" "security_context_t""'"); + } + arg1 = (security_context_t)(buf1); + result = (int)setfscreatecon(arg1); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_setfscreatecon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 = (security_context_t) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:setfscreatecon_raw",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "setfscreatecon_raw" "', argument " "1"" of type '" "security_context_t""'"); + } + arg1 = (security_context_t)(buf1); + result = (int)setfscreatecon_raw(arg1); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getkeycreatecon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = 0 ; + + arg1 = &temp1; + if (!PyArg_ParseTuple(args,(char *)":getkeycreatecon")) SWIG_fail; + result = (int)getkeycreatecon(arg1); + resultobj = SWIG_From_int((int)(result)); + if (*arg1) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg1)); + freecon(*arg1); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getkeycreatecon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = 0 ; + + arg1 = &temp1; + if (!PyArg_ParseTuple(args,(char *)":getkeycreatecon_raw")) SWIG_fail; + result = (int)getkeycreatecon_raw(arg1); + resultobj = SWIG_From_int((int)(result)); + if (*arg1) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg1)); + freecon(*arg1); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_setkeycreatecon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 = (security_context_t) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:setkeycreatecon",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "setkeycreatecon" "', argument " "1"" of type '" "security_context_t""'"); + } + arg1 = (security_context_t)(buf1); + result = (int)setkeycreatecon(arg1); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_setkeycreatecon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 = (security_context_t) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:setkeycreatecon_raw",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "setkeycreatecon_raw" "', argument " "1"" of type '" "security_context_t""'"); + } + arg1 = (security_context_t)(buf1); + result = (int)setkeycreatecon_raw(arg1); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getsockcreatecon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = 0 ; + + arg1 = &temp1; + if (!PyArg_ParseTuple(args,(char *)":getsockcreatecon")) SWIG_fail; + result = (int)getsockcreatecon(arg1); + resultobj = SWIG_From_int((int)(result)); + if (*arg1) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg1)); + freecon(*arg1); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getsockcreatecon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t *arg1 = (security_context_t *) 0 ; + int result; + security_context_t temp1 = 0 ; + + arg1 = &temp1; + if (!PyArg_ParseTuple(args,(char *)":getsockcreatecon_raw")) SWIG_fail; + result = (int)getsockcreatecon_raw(arg1); + resultobj = SWIG_From_int((int)(result)); + if (*arg1) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg1)); + freecon(*arg1); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_setsockcreatecon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 = (security_context_t) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:setsockcreatecon",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "setsockcreatecon" "', argument " "1"" of type '" "security_context_t""'"); + } + arg1 = (security_context_t)(buf1); + result = (int)setsockcreatecon(arg1); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_setsockcreatecon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 = (security_context_t) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:setsockcreatecon_raw",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "setsockcreatecon_raw" "', argument " "1"" of type '" "security_context_t""'"); + } + arg1 = (security_context_t)(buf1); + result = (int)setsockcreatecon_raw(arg1); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getfilecon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; char *arg1 = (char *) 0 ; - char *arg2 = (char *) 0 ; - security_context_t arg3 ; - security_context_t **arg4 = (security_context_t **) 0 ; + security_context_t *arg2 = (security_context_t *) 0 ; int result; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; + security_context_t temp2 = 0 ; PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OOOO:get_ordered_context_list_with_level",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + arg2 = &temp2; + if (!PyArg_ParseTuple(args,(char *)"O:getfilecon",&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_ordered_context_list_with_level" "', argument " "1"" of type '" "char const *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "getfilecon" "', argument " "1"" of type '" "char const *""'"); } arg1 = (char *)(buf1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "get_ordered_context_list_with_level" "', argument " "2"" of type '" "char const *""'"); + result = (int)getfilecon((char const *)arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + if (*arg2) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); + freecon(*arg2); } - arg2 = (char *)(buf2); - { - arg3 = (security_context_t)PyString_AsString(obj2); + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); } - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_p_security_context_t, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "get_ordered_context_list_with_level" "', argument " "4"" of type '" "security_context_t **""'"); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_getfilecon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + security_context_t *arg2 = (security_context_t *) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + security_context_t temp2 = 0 ; + PyObject * obj0 = 0 ; + + arg2 = &temp2; + if (!PyArg_ParseTuple(args,(char *)"O:getfilecon_raw",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "getfilecon_raw" "', argument " "1"" of type '" "char const *""'"); } - arg4 = (security_context_t **)(argp4); - result = (int)get_ordered_context_list_with_level((char const *)arg1,(char const *)arg2,arg3,arg4); + arg1 = (char *)(buf1); + result = (int)getfilecon_raw((char const *)arg1,arg2); resultobj = SWIG_From_int((int)(result)); + if (*arg2) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); + freecon(*arg2); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; fail: if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return NULL; } -SWIGINTERN PyObject *_wrap_get_default_context(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_lgetfilecon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; - security_context_t arg2 ; - security_context_t *arg3 = (security_context_t *) 0 ; + security_context_t *arg2 = (security_context_t *) 0 ; int result; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; - security_context_t temp3 = NULL ; - char *temp30 = NULL ; + security_context_t temp2 = 0 ; PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - { - arg3 = &temp3; + arg2 = &temp2; + if (!PyArg_ParseTuple(args,(char *)"O:lgetfilecon",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "lgetfilecon" "', argument " "1"" of type '" "char const *""'"); } - if (!PyArg_ParseTuple(args,(char *)"OO:get_default_context",&obj0,&obj1)) SWIG_fail; + arg1 = (char *)(buf1); + result = (int)lgetfilecon((char const *)arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + if (*arg2) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); + freecon(*arg2); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lgetfilecon_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + security_context_t *arg2 = (security_context_t *) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + security_context_t temp2 = 0 ; + PyObject * obj0 = 0 ; + + arg2 = &temp2; + if (!PyArg_ParseTuple(args,(char *)"O:lgetfilecon_raw",&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_default_context" "', argument " "1"" of type '" "char const *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "lgetfilecon_raw" "', argument " "1"" of type '" "char const *""'"); } arg1 = (char *)(buf1); - { - arg2 = (security_context_t)PyString_AsString(obj1); - } - result = (int)get_default_context((char const *)arg1,arg2,arg3); + result = (int)lgetfilecon_raw((char const *)arg1,arg2); resultobj = SWIG_From_int((int)(result)); - { - if (*arg3) - temp30 = *arg3; - else - temp30 = ""; - resultobj = SWIG_Python_AppendOutput(resultobj, PyString_FromString(temp30)); + if (*arg2) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); + freecon(*arg2); } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); return resultobj; fail: @@ -2942,12 +3643,76 @@ } -SWIGINTERN PyObject *_wrap_get_d... [truncated message content] |
From: <ew...@us...> - 2007-08-06 21:03:50
|
Revision: 2510 http://selinux.svn.sourceforge.net/selinux/?rev=2510&view=rev Author: ewalsh Date: 2007-08-06 14:03:48 -0700 (Mon, 06 Aug 2007) Log Message: ----------- Author: Eamon Walsh Email: ew...@ty... Subject: libselinux Patch to prevent segfault from un-initialized print statement Date: Fri, 03 Aug 2007 17:12:07 -0400 Please use the following instead, this is a result of the new labeling interface having its own logging callback. I tried to use the value of the function pointer to decide compatibility mode; this introduces a separate flag variable. Signed-off-by: Eamon Walsh <ew...@ty...> Acked-by: Stephen Smalley <sd...@ty...> Modified Paths: -------------- trunk/libselinux/src/label_internal.h trunk/libselinux/src/matchpathcon.c Modified: trunk/libselinux/src/label_internal.h =================================================================== --- trunk/libselinux/src/label_internal.h 2007-08-02 20:52:45 UTC (rev 2509) +++ trunk/libselinux/src/label_internal.h 2007-08-06 21:03:48 UTC (rev 2510) @@ -58,10 +58,11 @@ /* * Compatibility support */ +extern int myprintf_compat; extern void __attribute__ ((format(printf, 1, 2))) (*myprintf) (const char *fmt,...); -#define COMPAT_LOG(type, fmt...) if (myprintf) \ +#define COMPAT_LOG(type, fmt...) if (myprintf_compat) \ myprintf(fmt); \ else \ selinux_log(type, fmt); Modified: trunk/libselinux/src/matchpathcon.c =================================================================== --- trunk/libselinux/src/matchpathcon.c 2007-08-02 20:52:45 UTC (rev 2509) +++ trunk/libselinux/src/matchpathcon.c 2007-08-06 21:03:48 UTC (rev 2510) @@ -65,14 +65,13 @@ #ifdef __GNUC__ __attribute__ ((format(printf, 1, 2))) #endif - (*myprintf) (const char *fmt,...); + (*myprintf) (const char *fmt,...) = &default_printf; +int myprintf_compat = 0; void set_matchpathcon_printf(void (*f) (const char *fmt, ...)) { - if (f) - myprintf = f; - else - myprintf = &default_printf; + myprintf = f ? f : &default_printf; + myprintf_compat = 1; } static int (*myinvalidcon) (const char *p, unsigned l, char *c) = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2007-09-10 19:24:50
|
Revision: 2553 http://selinux.svn.sourceforge.net/selinux/?rev=2553&view=rev Author: ssmalley Date: 2007-09-10 12:24:47 -0700 (Mon, 10 Sep 2007) Log Message: ----------- Author: James Athey Email: ja...@tr... Subject: libselinux: fix rpm_execcon in SWIG bindings Date: Wed, 05 Sep 2007 15:35:22 -0400 On Tue, 2007-09-04 at 10:23 -0400, Daniel J Walsh wrote: > https://bugzilla.redhat.com/show_bug.cgi?id=276121 > > Bug in refactored SWIG Bindings. > > > #!/usr/bin/python > > import selinux > args = [ "/bin/bash", "--version" ] > selinux.rpm_execcon(0, args[0], args, [ ]) > > Produces: > > Traceback (most recent call last): > File "test.py", line 5, in <module> > selinux.rpm_execcon(0, args[0], args, [ ]) > TypeError: in method 'rpm_execcon', argument 3 of type 'char *const []' > > Version-Release number of selected component (if applicable): > libselinux-2.0.31-3.fc8 > > James do you have a nice quick fix for this? It's nice, it's quick, and I think it's a fix, but I'll let you be the judge of that. Modified Paths: -------------- trunk/libselinux/src/selinux.py trunk/libselinux/src/selinuxswig_python.i trunk/libselinux/src/selinuxswig_wrap.c Modified: trunk/libselinux/src/selinux.py =================================================================== --- trunk/libselinux/src/selinux.py 2007-09-10 19:23:04 UTC (rev 2552) +++ trunk/libselinux/src/selinux.py 2007-09-10 19:24:47 UTC (rev 2553) @@ -277,6 +277,7 @@ selinux_file_context_local_path = _selinux.selinux_file_context_local_path selinux_homedir_context_path = _selinux.selinux_homedir_context_path selinux_media_context_path = _selinux.selinux_media_context_path +selinux_x_context_path = _selinux.selinux_x_context_path selinux_contexts_path = _selinux.selinux_contexts_path selinux_securetty_types_path = _selinux.selinux_securetty_types_path selinux_booleans_path = _selinux.selinux_booleans_path Modified: trunk/libselinux/src/selinuxswig_python.i =================================================================== --- trunk/libselinux/src/selinuxswig_python.i 2007-09-10 19:23:04 UTC (rev 2552) +++ trunk/libselinux/src/selinuxswig_python.i 2007-09-10 19:24:47 UTC (rev 2553) @@ -98,4 +98,41 @@ } } +%typemap(in) char * const [] { + int i, size; + PyObject * s; + + if (!PySequence_Check($input)) { + PyErr_SetString(PyExc_ValueError, "Expected a sequence"); + return NULL; + } + + size = PySequence_Size($input); + + $1 = (char**) malloc(size + 1); + + for(i = 0; i < size; i++) { + if (!PyString_Check(PySequence_GetItem($input, i))) { + PyErr_SetString(PyExc_ValueError, "Sequence must contain only strings"); + return NULL; + } + } + + for(i = 0; i < size; i++) { + s = PySequence_GetItem($input, i); + $1[i] = (char*) malloc(PyString_Size(s) + 1); + strcpy($1[i], PyString_AsString(s)); + } + $1[size] = NULL; +} + +%typemap(freearg,match="in") char * const [] { + int i = 0; + while($1[i]) { + free($1[i]); + i++; + } + free($1); +} + %include "selinuxswig.i" Modified: trunk/libselinux/src/selinuxswig_wrap.c =================================================================== --- trunk/libselinux/src/selinuxswig_wrap.c 2007-09-10 19:23:04 UTC (rev 2552) +++ trunk/libselinux/src/selinuxswig_wrap.c 2007-09-10 19:24:47 UTC (rev 2553) @@ -6856,6 +6856,19 @@ } +SWIGINTERN PyObject *_wrap_selinux_x_context_path(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":selinux_x_context_path")) SWIG_fail; + result = (char *)selinux_x_context_path(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_selinux_contexts_path(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; char *result = 0 ; @@ -7078,10 +7091,6 @@ int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -7098,22 +7107,98 @@ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rpm_execcon" "', argument " "2"" of type '" "char const *""'"); } arg2 = (char *)(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_p_char, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "rpm_execcon" "', argument " "3"" of type '" "char *const []""'"); - } - arg3 = (char **)(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_p_char, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "rpm_execcon" "', argument " "4"" of type '" "char *const []""'"); - } - arg4 = (char **)(argp4); + { + int i, size; + PyObject * s; + + if (!PySequence_Check(obj2)) { + PyErr_SetString(PyExc_ValueError, "Expected a sequence"); + return NULL; + } + + size = PySequence_Size(obj2); + + arg3 = (char**) malloc(size + 1); + + for(i = 0; i < size; i++) { + if (!PyString_Check(PySequence_GetItem(obj2, i))) { + PyErr_SetString(PyExc_ValueError, "Sequence must contain only strings"); + return NULL; + } + } + + for(i = 0; i < size; i++) { + s = PySequence_GetItem(obj2, i); + arg3[i] = (char*) malloc(PyString_Size(s) + 1); + strcpy(arg3[i], PyString_AsString(s)); + } + arg3[size] = NULL; + } + { + int i, size; + PyObject * s; + + if (!PySequence_Check(obj3)) { + PyErr_SetString(PyExc_ValueError, "Expected a sequence"); + return NULL; + } + + size = PySequence_Size(obj3); + + arg4 = (char**) malloc(size + 1); + + for(i = 0; i < size; i++) { + if (!PyString_Check(PySequence_GetItem(obj3, i))) { + PyErr_SetString(PyExc_ValueError, "Sequence must contain only strings"); + return NULL; + } + } + + for(i = 0; i < size; i++) { + s = PySequence_GetItem(obj3, i); + arg4[i] = (char*) malloc(PyString_Size(s) + 1); + strcpy(arg4[i], PyString_AsString(s)); + } + arg4[size] = NULL; + } result = (int)rpm_execcon(arg1,(char const *)arg2,(char *const (*))arg3,(char *const (*))arg4); resultobj = SWIG_From_int((int)(result)); if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + { + int i = 0; + while(arg3[i]) { + free(arg3[i]); + i++; + } + free(arg3); + } + { + int i = 0; + while(arg4[i]) { + free(arg4[i]); + i++; + } + free(arg4); + } return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + { + int i = 0; + while(arg3[i]) { + free(arg3[i]); + i++; + } + free(arg3); + } + { + int i = 0; + while(arg4[i]) { + free(arg4[i]); + i++; + } + free(arg4); + } return NULL; } @@ -8002,6 +8087,7 @@ { (char *)"selinux_file_context_local_path", _wrap_selinux_file_context_local_path, METH_VARARGS, NULL}, { (char *)"selinux_homedir_context_path", _wrap_selinux_homedir_context_path, METH_VARARGS, NULL}, { (char *)"selinux_media_context_path", _wrap_selinux_media_context_path, METH_VARARGS, NULL}, + { (char *)"selinux_x_context_path", _wrap_selinux_x_context_path, METH_VARARGS, NULL}, { (char *)"selinux_contexts_path", _wrap_selinux_contexts_path, METH_VARARGS, NULL}, { (char *)"selinux_securetty_types_path", _wrap_selinux_securetty_types_path, METH_VARARGS, NULL}, { (char *)"selinux_booleans_path", _wrap_selinux_booleans_path, METH_VARARGS, NULL}, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2007-09-12 15:45:13
|
Revision: 2557 http://selinux.svn.sourceforge.net/selinux/?rev=2557&view=rev Author: ssmalley Date: 2007-09-12 08:45:09 -0700 (Wed, 12 Sep 2007) Log Message: ----------- Author: Stephen Smalley Email: sd...@ty... Subject: getfilecon return code Date: Mon, 09 Jul 2007 14:42:35 -0400 On Mon, 2007-07-09 at 14:30 -0400, Stephen Smalley wrote: > On Mon, 2007-07-09 at 14:07 -0400, John D. Ramsdell wrote: > > I hadn't carefully read the manual page for getfilecon until now, but > > I notice it states that a positive number is returned indicating the > > number of bytes malloc'd for the context, and -1 is returned > > indicating failure and that errno is set. I would have guessed from > > the description that zero is never an allowed return value. In fact, > > I wrote code that freecon'd a context whenever the return value was > > not -1. > > freecon(NULL) is perfectly legal and harmless, like free(NULL), so that > part is ok. > > It is possible to set extended attributes with no values, e.g. > $ setfattr -n user.foo /path/to/foo > $ getfattr -n user.foo /path/to/foo > and directly calling getxattr() on that file will return 0. > > So technically this is a possible case, even if it is unusual and was > introduced in this case by the proc sysctl rewrite in the kernel leaving > us with "private" /proc/sys inodes. > > I'd be inclined to change security_inode_getsecurity() in the kernel to > return -EOPNOTSUPP in the IS_PRIVATE(inode) case. But that won't help > with current kernels, of course. > > libselinux could remap a zero return from getxattr to a -1 return with > errno EOPNOTSUPP in the meantime if we want to present this behavior to > applications now. Like so: Modified Paths: -------------- trunk/libselinux/src/fgetfilecon.c trunk/libselinux/src/getfilecon.c trunk/libselinux/src/lgetfilecon.c Modified: trunk/libselinux/src/fgetfilecon.c =================================================================== --- trunk/libselinux/src/fgetfilecon.c 2007-09-10 19:30:31 UTC (rev 2556) +++ trunk/libselinux/src/fgetfilecon.c 2007-09-12 15:45:09 UTC (rev 2557) @@ -37,6 +37,11 @@ ret = fgetxattr(fd, XATTR_NAME_SELINUX, buf, size - 1); } out: + if (ret == 0) { + /* Re-map empty attribute values to errors. */ + errno = EOPNOTSUPP; + ret = -1; + } if (ret < 0) free(buf); else Modified: trunk/libselinux/src/getfilecon.c =================================================================== --- trunk/libselinux/src/getfilecon.c 2007-09-10 19:30:31 UTC (rev 2556) +++ trunk/libselinux/src/getfilecon.c 2007-09-12 15:45:09 UTC (rev 2557) @@ -37,6 +37,11 @@ ret = getxattr(path, XATTR_NAME_SELINUX, buf, size - 1); } out: + if (ret == 0) { + /* Re-map empty attribute values to errors. */ + errno = EOPNOTSUPP; + ret = -1; + } if (ret < 0) free(buf); else Modified: trunk/libselinux/src/lgetfilecon.c =================================================================== --- trunk/libselinux/src/lgetfilecon.c 2007-09-10 19:30:31 UTC (rev 2556) +++ trunk/libselinux/src/lgetfilecon.c 2007-09-12 15:45:09 UTC (rev 2557) @@ -37,6 +37,11 @@ ret = lgetxattr(path, XATTR_NAME_SELINUX, buf, size - 1); } out: + if (ret == 0) { + /* Re-map empty attribute values to errors. */ + errno = EOPNOTSUPP; + ret = -1; + } if (ret < 0) free(buf); else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2008-01-23 13:47:35
|
Revision: 2732 http://selinux.svn.sourceforge.net/selinux/?rev=2732&view=rev Author: ssmalley Date: 2008-01-23 05:47:32 -0800 (Wed, 23 Jan 2008) Log Message: ----------- Author: Daniel J Walsh Email: dw...@re... Subject: TypeError: in method 'getpidcon', argument 1 of type 'pid_t' Date: Tue, 08 Jan 2008 05:15:48 -0500 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Stephen Smalley wrote: > On Mon, 2008-01-07 at 10:08 -0600, Xavier Toth wrote: >> import selinux >> import os >> >> pid = os.getpid() >> print "Type of pid ", type(pid) >> (ret,con) = selinux.getpidcon(pid) >> type = con.split(":", 4) >> print type >> >> Running this script results in: >> >> Type of pid <type 'int'> >> Traceback (most recent call last): >> File "test.py", line 8, in <module> >> (ret,con) = selinux.getpidcon(pid) >> TypeError: in method 'getpidcon', argument 1 of type 'pid_t' >> >> How do I make a pid_t in python? Or is the swig broke? > > Possibly we need a typemap for it in the python binding? > Patch to add pid_t typemap Modified Paths: -------------- trunk/libselinux/src/selinux.py trunk/libselinux/src/selinuxswig.i trunk/libselinux/src/selinuxswig_wrap.c Modified: trunk/libselinux/src/selinux.py =================================================================== --- trunk/libselinux/src/selinux.py 2008-01-21 15:42:48 UTC (rev 2731) +++ trunk/libselinux/src/selinux.py 2008-01-23 13:47:32 UTC (rev 2732) @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.31 +# Version 1.3.33 # # Don't modify this file, modify the SWIG interface instead. # This file is compatible with both classic and new-style classes. Modified: trunk/libselinux/src/selinuxswig.i =================================================================== --- trunk/libselinux/src/selinuxswig.i 2008-01-21 15:42:48 UTC (rev 2731) +++ trunk/libselinux/src/selinuxswig.i 2008-01-23 13:47:32 UTC (rev 2732) @@ -10,6 +10,7 @@ %apply int *OUTPUT { size_t * }; %typedef unsigned mode_t; +%typedef unsigned pid_t; %typemap(in, numinputs=0) (char ***names, int *len) (char **temp1, int temp2) { $1 = &temp1; Modified: trunk/libselinux/src/selinuxswig_wrap.c =================================================================== --- trunk/libselinux/src/selinuxswig_wrap.c 2008-01-21 15:42:48 UTC (rev 2731) +++ trunk/libselinux/src/selinuxswig_wrap.c 2008-01-23 13:47:32 UTC (rev 2732) @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.31 + * Version 1.3.33 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -17,14 +17,14 @@ /* template workaround for compilers that cannot correctly implement the C++ standard */ #ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) -# if (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template # else -# define SWIGTEMPLATEDISAMBIGUATOR +# define SWIGTEMPLATEDISAMBIGUATOR # endif #endif @@ -107,7 +107,13 @@ # define _CRT_SECURE_NO_DEPRECATE #endif +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + /* Python.h has to appear first */ #include <Python.h> @@ -343,7 +349,7 @@ while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } - return (l1 - f1) - (l2 - f2); + return (int)((l1 - f1) - (l2 - f2)); } /* @@ -1090,14 +1096,14 @@ /* Unpack the argument tuple */ SWIGINTERN int -SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs) +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { if (!args) { if (!min && !max) { return 1; } else { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", - name, (min == max ? "" : "at least "), min); + name, (min == max ? "" : "at least "), (int)min); return 0; } } @@ -1105,14 +1111,14 @@ PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); return 0; } else { - register int l = PyTuple_GET_SIZE(args); + register Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), min, l); + name, (min == max ? "" : "at least "), (int)min, (int)l); return 0; } else if (l > max) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), max, l); + name, (min == max ? "" : "at most "), (int)max, (int)l); return 0; } else { register int i; @@ -1591,9 +1597,11 @@ (unaryfunc)0, /*nb_float*/ (unaryfunc)PySwigObject_oct, /*nb_oct*/ (unaryfunc)PySwigObject_hex, /*nb_hex*/ -#if PY_VERSION_HEX >= 0x02020000 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#elif PY_VERSION_HEX >= 0x02000000 +#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ +#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ #endif }; @@ -2458,14 +2466,13 @@ #define SWIGTYPE_p_int swig_types[7] #define SWIGTYPE_p_p_char swig_types[8] #define SWIGTYPE_p_p_p_char swig_types[9] -#define SWIGTYPE_p_pid_t swig_types[10] -#define SWIGTYPE_p_security_class_mapping swig_types[11] -#define SWIGTYPE_p_selinux_callback swig_types[12] -#define SWIGTYPE_p_selinux_opt swig_types[13] -#define SWIGTYPE_p_unsigned_int swig_types[14] -#define SWIGTYPE_p_unsigned_short swig_types[15] -static swig_type_info *swig_types[17]; -static swig_module_info swig_module = {swig_types, 16, 0, 0, 0, 0}; +#define SWIGTYPE_p_security_class_mapping swig_types[10] +#define SWIGTYPE_p_selinux_callback swig_types[11] +#define SWIGTYPE_p_selinux_opt swig_types[12] +#define SWIGTYPE_p_unsigned_int swig_types[13] +#define SWIGTYPE_p_unsigned_short swig_types[14] +static swig_type_info *swig_types[16]; +static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -2484,7 +2491,7 @@ #define SWIG_name "_selinux" -#define SWIGVERSION 0x010331 +#define SWIGVERSION 0x010333 #define SWIG_VERSION SWIGVERSION @@ -2577,15 +2584,13 @@ #include <limits.h> -#ifndef LLONG_MIN -# define LLONG_MIN LONG_LONG_MIN +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif #endif -#ifndef LLONG_MAX -# define LLONG_MAX LONG_LONG_MAX -#endif -#ifndef ULLONG_MAX -# define ULLONG_MAX ULONG_LONG_MAX -#endif SWIGINTERN int @@ -2669,13 +2674,18 @@ SWIGINTERN int -SWIG_AsVal_long (PyObject *obj, long* val) +SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) { if (PyInt_Check(obj)) { - if (val) *val = PyInt_AsLong(obj); - return SWIG_OK; + long v = PyInt_AsLong(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } } else if (PyLong_Check(obj)) { - long v = PyLong_AsLong(obj); + unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; @@ -2686,7 +2696,7 @@ #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; - long v = PyInt_AsLong(obj); + unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); @@ -2696,8 +2706,8 @@ if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { - if (val) *val = (long)(d); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); return res; } } @@ -2708,15 +2718,15 @@ SWIGINTERN int -SWIG_AsVal_int (PyObject * obj, int *val) +SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) { - long v; - int res = SWIG_AsVal_long (obj, &v); + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); if (SWIG_IsOK(res)) { - if ((v < INT_MIN || v > INT_MAX)) { + if ((v > UINT_MAX)) { return SWIG_OverflowError; } else { - if (val) *val = (int)(v); + if (val) *val = (unsigned int)(v); } } return res; @@ -2724,18 +2734,13 @@ SWIGINTERN int -SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) +SWIG_AsVal_long (PyObject *obj, long* val) { if (PyInt_Check(obj)) { - long v = PyInt_AsLong(obj); - if (v >= 0) { - if (val) *val = v; - return SWIG_OK; - } else { - return SWIG_OverflowError; - } + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; } else if (PyLong_Check(obj)) { - unsigned long v = PyLong_AsUnsignedLong(obj); + long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; @@ -2746,7 +2751,7 @@ #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; - unsigned long v = PyLong_AsUnsignedLong(obj); + long v = PyInt_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); @@ -2756,8 +2761,8 @@ if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { - if (val) *val = (unsigned long)(d); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); return res; } } @@ -2768,15 +2773,15 @@ SWIGINTERN int -SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) +SWIG_AsVal_int (PyObject * obj, int *val) { - unsigned long v; - int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + long v; + int res = SWIG_AsVal_long (obj, &v); if (SWIG_IsOK(res)) { - if ((v > UINT_MAX)) { + if ((v < INT_MIN || v > INT_MAX)) { return SWIG_OverflowError; } else { - if (val) *val = (unsigned int)(v); + if (val) *val = (int)(v); } } return res; @@ -2986,24 +2991,18 @@ pid_t arg1 ; security_context_t *arg2 = (security_context_t *) 0 ; int result; - void *argp1 ; - int res1 = 0 ; + unsigned int val1 ; + int ecode1 = 0 ; security_context_t temp2 = 0 ; PyObject * obj0 = 0 ; arg2 = &temp2; if (!PyArg_ParseTuple(args,(char *)"O:getpidcon",&obj0)) SWIG_fail; - { - res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_pid_t, 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "getpidcon" "', argument " "1"" of type '" "pid_t""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "getpidcon" "', argument " "1"" of type '" "pid_t""'"); - } else { - arg1 = *((pid_t *)(argp1)); - } - } + ecode1 = SWIG_AsVal_unsigned_SS_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "getpidcon" "', argument " "1"" of type '" "pid_t""'"); + } + arg1 = (pid_t)(val1); result = (int)getpidcon(arg1,arg2); resultobj = SWIG_From_int((int)(result)); if (*arg2) { @@ -3025,24 +3024,18 @@ pid_t arg1 ; security_context_t *arg2 = (security_context_t *) 0 ; int result; - void *argp1 ; - int res1 = 0 ; + unsigned int val1 ; + int ecode1 = 0 ; security_context_t temp2 = 0 ; PyObject * obj0 = 0 ; arg2 = &temp2; if (!PyArg_ParseTuple(args,(char *)"O:getpidcon_raw",&obj0)) SWIG_fail; - { - res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_pid_t, 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "getpidcon_raw" "', argument " "1"" of type '" "pid_t""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "getpidcon_raw" "', argument " "1"" of type '" "pid_t""'"); - } else { - arg1 = *((pid_t *)(argp1)); - } - } + ecode1 = SWIG_AsVal_unsigned_SS_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "getpidcon_raw" "', argument " "1"" of type '" "pid_t""'"); + } + arg1 = (pid_t)(val1); result = (int)getpidcon_raw(arg1,arg2); resultobj = SWIG_From_int((int)(result)); if (*arg2) { @@ -8149,7 +8142,7 @@ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ static swig_type_info _swigt__p_SELboolean = {"_p_SELboolean", "SELboolean *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_av_decision = {"_p_av_decision", "struct av_decision *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_av_decision = {"_p_av_decision", "struct av_decision *|av_decision *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_f_int_p_q_const__char_v_______int = {"_p_f_int_p_q_const__char_v_______int", "int (*)(int,char const *,...)", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_f_p_p_char__int = {"_p_f_p_p_char__int", "int (*)(char **)|int (*)(security_context_t *)", 0, 0, (void*)0, 0}; @@ -8158,12 +8151,11 @@ static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **|security_context_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_p_p_char = {"_p_p_p_char", "char ***|security_context_t **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_pid_t = {"_p_pid_t", "pid_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_security_class_mapping = {"_p_security_class_mapping", "struct security_class_mapping *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_selinux_callback = {"_p_selinux_callback", "union selinux_callback *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_selinux_opt = {"_p_selinux_opt", "selinux_opt *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "unsigned int *|access_vector_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|security_class_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_security_class_mapping = {"_p_security_class_mapping", "struct security_class_mapping *|security_class_mapping *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_selinux_callback = {"_p_selinux_callback", "union selinux_callback *|selinux_callback *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_selinux_opt = {"_p_selinux_opt", "struct selinux_opt *|selinux_opt *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "unsigned int *|access_vector_t *|mode_t *|pid_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "security_class_t *|unsigned short *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { &_swigt__p_SELboolean, @@ -8176,7 +8168,6 @@ &_swigt__p_int, &_swigt__p_p_char, &_swigt__p_p_p_char, - &_swigt__p_pid_t, &_swigt__p_security_class_mapping, &_swigt__p_selinux_callback, &_swigt__p_selinux_opt, @@ -8194,7 +8185,6 @@ static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_p_char[] = { {&_swigt__p_p_p_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_pid_t[] = { {&_swigt__p_pid_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_security_class_mapping[] = { {&_swigt__p_security_class_mapping, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_selinux_callback[] = { {&_swigt__p_selinux_callback, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_selinux_opt[] = { {&_swigt__p_selinux_opt, 0, 0, 0},{0, 0, 0, 0}}; @@ -8212,7 +8202,6 @@ _swigc__p_int, _swigc__p_p_char, _swigc__p_p_p_char, - _swigc__p_pid_t, _swigc__p_security_class_mapping, _swigc__p_selinux_callback, _swigc__p_selinux_opt, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2008-01-23 13:59:35
|
Revision: 2733 http://selinux.svn.sourceforge.net/selinux/?rev=2733&view=rev Author: ssmalley Date: 2008-01-23 05:59:29 -0800 (Wed, 23 Jan 2008) Log Message: ----------- Author: Daniel J Walsh Email: dw...@re... Subject: Swig patch for libselinux to stop warning messages and update to latest swig Date: Fri, 11 Jan 2008 13:59:53 -0500 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Todd Miller wrote: > Is "security_contextx_t" a typo? > > - todd Yes, And I don't think we need that line. It was added for something else I was attempting and no longer do. (obviously.) Updated patch. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iEYEARECAAYFAkeHvKgACgkQrlYvE4MpobMVlQCg1L3TYAU1qbrnemuFhz5bgRTQ eXgAn3462Yl1VgldAuUIxDiqf+TSHBv0 =l+ts -----END PGP SIGNATURE----- Modified Paths: -------------- trunk/libselinux/src/selinuxswig.i trunk/libselinux/src/selinuxswig_wrap.c Modified: trunk/libselinux/src/selinuxswig.i =================================================================== --- trunk/libselinux/src/selinuxswig.i 2008-01-23 13:47:32 UTC (rev 2732) +++ trunk/libselinux/src/selinuxswig.i 2008-01-23 13:59:29 UTC (rev 2733) @@ -5,6 +5,9 @@ %module selinux %{ #include "selinux/selinux.h" + #include "../include/selinux/selinux.h" + #include "../include/selinux/get_default_type.h" + #include "../include/selinux/get_context_list.h" %} %apply int *OUTPUT { int *enforce }; %apply int *OUTPUT { size_t * }; Modified: trunk/libselinux/src/selinuxswig_wrap.c =================================================================== --- trunk/libselinux/src/selinuxswig_wrap.c 2008-01-23 13:47:32 UTC (rev 2732) +++ trunk/libselinux/src/selinuxswig_wrap.c 2008-01-23 13:59:29 UTC (rev 2733) @@ -2503,6 +2503,9 @@ #include "selinux/selinux.h" + #include "../include/selinux/selinux.h" + #include "../include/selinux/get_default_type.h" + #include "../include/selinux/get_context_list.h" #define SWIG_From_long PyInt_FromLong This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2008-01-23 20:22:39
|
Revision: 2740 http://selinux.svn.sourceforge.net/selinux/?rev=2740&view=rev Author: ssmalley Date: 2008-01-23 12:22:37 -0800 (Wed, 23 Jan 2008) Log Message: ----------- Author: Daniel J Walsh Email: dw...@re... Subject: Patch to add python audit2why bindings. Date: Fri, 11 Jan 2008 11:03:54 -0500 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Updated policycoreutils will be coming to take advantage of these bindings. setroubleshoot will also. import selinux will work the way it always did, but now you can execute import selinux.audit2allow as audit2allow audit2allow.init() for i in avc: print audit2allow.analyze(i.scon, i,tcon, i,class, i.access) audit2allow.finish() And get the reason for the AVC. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iEYEARECAAYFAkeHk2kACgkQrlYvE4MpobPJHACgqRs9BJ9tKwYSQJUR+AjjqXIF 7foAoLcHRAbEE4GAr9DFWopttFOqd/ra =rrAB -----END PGP SIGNATURE----- Modified Paths: -------------- trunk/libselinux/src/Makefile Added Paths: ----------- trunk/libselinux/src/audit2why.c Modified: trunk/libselinux/src/Makefile =================================================================== --- trunk/libselinux/src/Makefile 2008-01-23 14:26:14 UTC (rev 2739) +++ trunk/libselinux/src/Makefile 2008-01-23 20:22:37 UTC (rev 2740) @@ -18,6 +18,7 @@ SWIGSO=_selinux.so SWIGFILES=$(SWIGSO) selinux.py LIBSO=$(TARGET).$(LIBVERSION) +AUDIT2WHYSO=audit2why.so ifeq ($(DISABLE_AVC),y) UNUSED_SRCS+=avc.c avc_internal.c avc_sidtab.c mapping.c stringrep.c checkAccess.c @@ -28,7 +29,7 @@ ifeq ($(DISABLE_RPM),y) UNUSED_SRCS+=rpm.c endif -SRCS= $(filter-out $(UNUSED_SRCS), $(filter-out $(SWIGCOUT),$(wildcard *.c))) +SRCS= $(filter-out $(UNUSED_SRCS), $(filter-out audit2why.c $(SWIGCOUT),$(wildcard *.c))) OBJS= $(patsubst %.c,%.o,$(SRCS)) LOBJS= $(patsubst %.c,%.lo,$(SRCS)) @@ -47,7 +48,7 @@ all: $(LIBA) $(LIBSO) -pywrap: all $(SWIGSO) +pywrap: all $(SWIGSO) $(AUDIT2WHYSO) $(LIBA): $(OBJS) $(AR) rcs $@ $^ @@ -63,6 +64,12 @@ $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -ldl -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro ln -sf $@ $(TARGET) +audit2why.lo: audit2why.c + $(CC) $(CFLAGS) -I$(PYINC) -fPIC -DSHARED -c -o $@ $< + +$(AUDIT2WHYSO): audit2why.lo + $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -L. -lselinux ${LIBDIR}/libsepol.a -L$(LIBDIR) -Wl,-soname,$@ + %.o: %.c policy.h $(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $< @@ -83,14 +90,16 @@ cd $(LIBDIR) && ln -sf ../../`basename $(SHLIBDIR)`/$(LIBSO) $(TARGET) install-pywrap: pywrap - test -d $(PYTHONLIBDIR)/site-packages || install -m 755 -d $(PYTHONLIBDIR)/site-packages - install -m 755 $(SWIGFILES) $(PYTHONLIBDIR)/site-packages + test -d $(PYTHONLIBDIR)/site-packages/selinux || install -m 755 -d $(PYTHONLIBDIR)/site-packages/selinux + install -m 755 $(SWIGSO) $(PYTHONLIBDIR)/site-packages/selinux + install -m 755 $(AUDIT2WHYSO) $(PYTHONLIBDIR)/site-packages/selinux + install -m 644 selinux.py $(PYTHONLIBDIR)/site-packages/selinux/__init__.py relabel: /sbin/restorecon $(SHLIBDIR)/$(LIBSO) clean: - -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(TARGET) + -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ distclean: clean rm -f $(SWIGCOUT) $(SWIGFILES) Added: trunk/libselinux/src/audit2why.c =================================================================== --- trunk/libselinux/src/audit2why.c (rev 0) +++ trunk/libselinux/src/audit2why.c 2008-01-23 20:22:37 UTC (rev 2740) @@ -0,0 +1,460 @@ +#include <unistd.h> +#include <stdlib.h> +#include <ctype.h> +#include <errno.h> +#include <getopt.h> +#include <limits.h> +#include <sepol/sepol.h> +#include <sepol/policydb/services.h> +#include <Python.h> +#include <selinux/selinux.h> + +#define UNKNOWN -1 +#define BADSCON -2 +#define BADTCON -3 +#define BADTCLASS -4 +#define BADPERM -5 +#define BADCOMPUTE -6 +#define NOPOLICY -7 +#define ALLOW 0 +#define DONTAUDIT 1 +#define TERULE 2 +#define BOOLEAN 3 +#define CONSTRAINT 4 +#define RBAC 5 + +struct boolean_t { + char *name; + int active; +}; + +static struct boolean_t **boollist = NULL; +static int boolcnt = 0; + +struct avc_t { + sepol_handle_t *handle; + policydb_t policydb; + sepol_security_id_t ssid; + sepol_security_id_t tsid; + sepol_security_class_t tclass; + sepol_access_vector_t av; +}; + +static struct avc_t *avc = NULL; + +static sidtab_t sidtab; + +static int load_booleans(const sepol_bool_t * boolean, + void *arg __attribute__ ((__unused__))) +{ + boollist[boolcnt] = + (struct boolean_t *)malloc(sizeof(struct boolean_t)); + boollist[boolcnt]->name = strdup(sepol_bool_get_name(boolean)); + boollist[boolcnt]->active = sepol_bool_get_value(boolean); + boolcnt++; + return 0; +} + +static int check_booleans(struct avc_t *avc, struct boolean_t ***bools) +{ + char errormsg[PATH_MAX]; + struct sepol_av_decision avd; + unsigned int reason; + int rc; + int i; + sepol_bool_key_t *key = NULL; + sepol_bool_t *boolean = NULL; + int fcnt = 0; + int *foundlist = calloc(boolcnt, sizeof(int)); + if (!foundlist) { + PyErr_SetString( PyExc_MemoryError, "Out of memory\n"); + return fcnt; + } + for (i = 0; i < boolcnt; i++) { + char *name = boollist[i]->name; + int active = boollist[i]->active; + rc = sepol_bool_key_create(avc->handle, name, &key); + if (rc < 0) { + PyErr_SetString( PyExc_RuntimeError, + "Could not create boolean key.\n"); + break; + } + rc = sepol_bool_query(avc->handle, + (sepol_policydb_t *) & avc->policydb, + key, &boolean); + + if (rc < 0) { + snprintf(errormsg, sizeof(errormsg), + "Could not find boolean %s.\n", name); + PyErr_SetString( PyExc_RuntimeError, errormsg); + break; + } + + sepol_bool_set_value(boolean, !active); + + rc = sepol_bool_set(avc->handle, + (sepol_policydb_t *) & avc->policydb, + key, boolean); + if (rc < 0) { + snprintf(errormsg, sizeof(errormsg), + "Could not set boolean data %s.\n", name); + PyErr_SetString( PyExc_RuntimeError, errormsg); + break; + } + + /* Reproduce the computation. */ + rc = sepol_compute_av_reason(avc->ssid, avc->tsid, avc->tclass, + avc->av, &avd, &reason); + if (rc < 0) { + snprintf(errormsg, sizeof(errormsg), + "Error during access vector computation, skipping..."); + PyErr_SetString( PyExc_RuntimeError, errormsg); + + sepol_bool_free(boolean); + break; + } else { + if (!reason) { + foundlist[fcnt] = i; + fcnt++; + } + sepol_bool_set_value((sepol_bool_t *) boolean, active); + rc = sepol_bool_set(avc->handle, + (sepol_policydb_t *) & avc-> + policydb, key, + (sepol_bool_t *) boolean); + if (rc < 0) { + snprintf(errormsg, sizeof(errormsg), + "Could not set boolean data %s.\n", + name); + + PyErr_SetString( PyExc_RuntimeError, errormsg); + break; + } + } + sepol_bool_free(boolean); + sepol_bool_key_free(key); + key = NULL; + boolean = NULL; + } + if (key) + sepol_bool_key_free(key); + + if (boolean) + sepol_bool_free(boolean); + + if (fcnt > 0) { + *bools = (struct boolean_t **) + calloc(sizeof(struct boolean_t), fcnt + 1); + struct boolean_t *b = (struct boolean_t *) *bools; + for (i = 0; i < fcnt; i++) { + int ctr = foundlist[i]; + b[i].name = strdup(boollist[ctr]->name); + b[i].active = !boollist[ctr]->active; + } + } + free(foundlist); + return fcnt; +} + +static PyObject *finish(PyObject *self __attribute__((unused)), PyObject *args) { + PyObject *result = 0; + + if (PyArg_ParseTuple(args,(char *)":finish")) { + int i = 0; + for (i = 0; i < boolcnt; i++) { + free(boollist[i]->name); + free(boollist[i]); + } + free(boollist); + sepol_sidtab_shutdown(&sidtab); + sepol_sidtab_destroy(&sidtab); + policydb_destroy(&avc->policydb); + sepol_handle_destroy(avc->handle); + free(avc); + avc = NULL; + boollist = NULL; + boolcnt = 0; + + /* Boilerplate to return "None" */ + Py_RETURN_NONE; + } + return result; +} + + +static int __policy_init(const char *init_path) +{ + FILE *fp; + int vers = 0; + char path[PATH_MAX]; + char errormsg[PATH_MAX]; + struct policy_file pf; + int rc; + unsigned int cnt; + + if (init_path) { + strncpy(path, init_path, PATH_MAX); + fp = fopen(path, "r"); + if (!fp) { + snprintf(errormsg, sizeof(errormsg), + "unable to open %s: %s\n", + path, strerror(errno)); + PyErr_SetString( PyExc_ValueError, errormsg); + return 0; // trigger exception + } + } else { + vers = security_policyvers(); + if (vers < 0) { + snprintf(errormsg, sizeof(errormsg), + "Could not get policy version: %s\n", + strerror(errno)); + PyErr_SetString( PyExc_ValueError, errormsg); + return 1; + } + snprintf(path, PATH_MAX, "%s.%d", + selinux_binary_policy_path(), vers); + fp = fopen(path, "r"); + while (!fp && errno == ENOENT && --vers) { + snprintf(path, PATH_MAX, "%s.%d", + selinux_binary_policy_path(), vers); + fp = fopen(path, "r"); + } + if (!fp) { + snprintf(errormsg, sizeof(errormsg), + "unable to open %s.%d: %s\n", + selinux_binary_policy_path(), + security_policyvers(), strerror(errno)); + PyErr_SetString( PyExc_ValueError, errormsg); + return 1; + } + } + + avc = calloc(sizeof(struct avc_t), 1); + if (!avc) { + PyErr_SetString( PyExc_MemoryError, "Out of memory\n"); + return 1; + } + + /* Set up a policydb directly so that we can mutate it later + for booleans and user settings. Otherwise we would just use + sepol_set_policydb_from_file() here. */ + pf.fp = fp; + pf.type = PF_USE_STDIO; + if (policydb_init(&avc->policydb)) { + snprintf(errormsg, sizeof(errormsg), + "policydb_init failed: %s\n", strerror(errno)); + PyErr_SetString( PyExc_RuntimeError, errormsg); + fclose(fp); + return 1; + } + if (policydb_read(&avc->policydb, &pf, 0)) { + snprintf(errormsg, sizeof(errormsg), + "invalid binary policy %s\n", path); + PyErr_SetString( PyExc_ValueError, errormsg); + fclose(fp); + return 1; + } + fclose(fp); + sepol_set_policydb(&avc->policydb); + if (!init_path) { + /* If they didn't specify a full path of a binary policy file, + then also try loading any boolean settings and user + definitions from the active locations. Otherwise, + they can use genpolbools and genpolusers to build a + binary policy file that includes any desired settings + and then apply audit2why -p to the resulting file. + Errors are non-fatal as such settings are optional. */ + sepol_debug(0); + (void)sepol_genbools_policydb(&avc->policydb, + selinux_booleans_path()); + (void)sepol_genusers_policydb(&avc->policydb, + selinux_users_path()); + } + avc->handle = sepol_handle_create(); + + rc = sepol_bool_count(avc->handle, + (sepol_policydb_t *) & avc->policydb, &cnt); + if (rc < 0) { + PyErr_SetString( PyExc_RuntimeError, "unable to get bool count\n"); + return 1; + } + + boollist = calloc(cnt, sizeof(struct boolean_t)); + if (!boollist) { + PyErr_SetString( PyExc_MemoryError, "Out of memory\n"); + return 1; + } + + sepol_bool_iterate(avc->handle, + (const sepol_policydb_t *)&avc->policydb, + load_booleans, (void *)NULL); + + /* Initialize the sidtab for subsequent use by sepol_context_to_sid + and sepol_compute_av_reason. */ + rc = sepol_sidtab_init(&sidtab); + if (rc < 0) { + PyErr_SetString( PyExc_RuntimeError, "unable to init sidtab\n"); + free(boollist); + return 1; + } + sepol_set_sidtab(&sidtab); + return 0; +} + +static PyObject *init(PyObject *self __attribute__((unused)), PyObject *args) { + int result; + char *init_path=NULL; + if (PyArg_ParseTuple(args,(char *)"|s:policy_init",&init_path)) + result = __policy_init(init_path); + return Py_BuildValue("i", result); +} + +#define RETURN(X) \ + PyTuple_SetItem(result, 0, Py_BuildValue("i", X)); \ + return result; + +static PyObject *analyze(PyObject *self __attribute__((unused)) , PyObject *args) { + security_context_t scon; + security_context_t tcon; + char *tclassstr; + PyObject *listObj; + PyObject *strObj; + int numlines; + struct boolean_t **bools; + unsigned int reason; + sepol_security_id_t ssid, tsid; + sepol_security_class_t tclass; + sepol_access_vector_t perm, av; + struct sepol_av_decision avd; + int rc; + int i=0; + PyObject *result = PyTuple_New(2); + if (!result) return NULL; + Py_INCREF(Py_None); + PyTuple_SetItem(result, 1, Py_None); + + if (!PyArg_ParseTuple(args,(char *)"sssO!:audit2why",&scon,&tcon,&tclassstr,&PyList_Type, &listObj)) + return NULL; + + /* get the number of lines passed to us */ + numlines = PyList_Size(listObj); + + /* should raise an error here. */ + if (numlines < 0) return NULL; /* Not a list */ + + if (!avc) { + RETURN(NOPOLICY) + } + + rc = sepol_context_to_sid(scon, strlen(scon) + 1, &ssid); + if (rc < 0) { + RETURN(BADSCON) + } + rc = sepol_context_to_sid(tcon, strlen(tcon) + 1, &tsid); + if (rc < 0) { + RETURN(BADTCON) + } + tclass = string_to_security_class(tclassstr); + if (!tclass) { + RETURN(BADTCLASS) + } + /* Convert the permission list to an AV. */ + av = 0; + + /* iterate over items of the list, grabbing strings, and parsing + for numbers */ + for (i=0; i<numlines; i++){ + char *permstr; + + /* grab the string object from the next element of the list */ + strObj = PyList_GetItem(listObj, i); /* Can't fail */ + + /* make it a string */ + permstr = PyString_AsString( strObj ); + + perm = string_to_av_perm(tclass, permstr); + if (!perm) { + RETURN(BADPERM) + } + av |= perm; + } + + /* Reproduce the computation. */ + rc = sepol_compute_av_reason(ssid, tsid, tclass, av, &avd, &reason); + if (rc < 0) { + RETURN(BADCOMPUTE) + } + + if (!reason) { + RETURN(ALLOW) + } + if (reason & SEPOL_COMPUTEAV_TE) { + avc->ssid = ssid; + avc->tsid = tsid; + avc->tclass = tclass; + avc->av = av; + if (check_booleans(avc, &bools) == 0) { + if (av & ~avd.auditdeny) { + RETURN(DONTAUDIT) + } else { + RETURN(TERULE) + } + } else { + PyTuple_SetItem(result, 0, Py_BuildValue("i", BOOLEAN)); + struct boolean_t *b=(struct boolean_t *) bools; + int len=0; + while (b->name) { + len++; b++; + } + b = (struct boolean_t *) bools; + PyObject *boollist = PyTuple_New(len); + len=0; + while(b->name) { + PyObject *bool = Py_BuildValue("(si)", b->name, b->active); + PyTuple_SetItem(boollist, len++, bool); + b++; + } + free(bools); + PyTuple_SetItem(result, 1, boollist); + return result; + } + } + + if (reason & SEPOL_COMPUTEAV_CONS) { + RETURN(CONSTRAINT); + } + + if (reason & SEPOL_COMPUTEAV_RBAC) { + RETURN(RBAC) + } + RETURN(BADCOMPUTE) +} + +static PyMethodDef audit2whyMethods[] = { + {"init", init, METH_VARARGS, + "Initialize policy database."}, + {"analyze", analyze, METH_VARARGS, + "Analyze AVC."}, + {"finish", finish, METH_VARARGS, + "Finish using policy, free memory."}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +PyMODINIT_FUNC +initaudit2why(void) +{ + PyObject *m = Py_InitModule("audit2why", audit2whyMethods); + PyModule_AddIntConstant(m,"UNKNOWN", UNKNOWN); + PyModule_AddIntConstant(m,"BADSCON", BADSCON); + PyModule_AddIntConstant(m,"BADTCON", BADTCON); + PyModule_AddIntConstant(m,"BADTCLASS", BADTCLASS); + PyModule_AddIntConstant(m,"BADPERM", BADPERM); + PyModule_AddIntConstant(m,"BADCOMPUTE", BADCOMPUTE); + PyModule_AddIntConstant(m,"NOPOLICY", NOPOLICY); + PyModule_AddIntConstant(m,"ALLOW", ALLOW); + PyModule_AddIntConstant(m,"DONTAUDIT", DONTAUDIT); + PyModule_AddIntConstant(m,"TERULE", TERULE); + PyModule_AddIntConstant(m,"BOOLEAN", BOOLEAN); + PyModule_AddIntConstant(m,"CONSTRAINT", CONSTRAINT); + PyModule_AddIntConstant(m,"RBAC", RBAC); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2008-02-28 20:38:16
|
Revision: 2821 http://selinux.svn.sourceforge.net/selinux/?rev=2821&view=rev Author: ssmalley Date: 2008-02-28 12:38:11 -0800 (Thu, 28 Feb 2008) Log Message: ----------- Author: Daniel J Walsh Email: dw...@re... Subject: libselinux does not work properly in upstart/initrd Date: Thu, 28 Feb 2008 14:35:48 -0500 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Stephen Smalley wrote: > On Thu, 2008-02-28 at 13:48 -0500, Daniel J Walsh wrote: > Stephen Smalley wrote: >>>> On Thu, 2008-02-28 at 12:33 -0500, Daniel J Walsh wrote: >>>>> -----BEGIN PGP SIGNED MESSAGE----- >>>>> Hash: SHA1 >>>>> >>>>> https://bugzilla.redhat.com/show_bug.cgi?id=434793 >>>>> >>>>> The way the upstart initrd works is to run nash with a builtin >>>>> loadpolicy. The problem is nash starts before the /sysmount files >>>>> system is mounted, so libselinux does not have an /etc/selinux/config to >>>>> read. It defaults to targeted. So when nash finally executes >>>>> loadpolicy (selinux_init_load_policy) it has the wrong config. >>>>> Switching to any other type of policy will fail and >>>>> selinux_init_load_policy will look for targeted. >>>>> >>>>> I changed this function to reload the config, to fix this problem. >>>>> >>>>> I think I did all the hidden stuff correctly. I don't think we want to >>>>> expose these functions. >>>> To make a function hidden, just mark it with hidden. >>>> hidden_def and hidden_proto are about creating a private definition >>>> within the library for intra-library calls that do not cause a >>>> relocation, not about hiding the definition altogether. >>>> > So the hidden_def and hidden_proto lines can be removed as login as the > extern hidden remains. >>>> Concerns about this patch: >>>> - it isn't thread safe, > selinux_init_load_policy should not be called repeatedly, or probably > from a threaded app. >>>> - it only "fixes" the load policy case, not any other libselinux >>>> function call. > Well this is a very strange occurrance where the config is not there and > then when the function gets called, it is there. > >> Fair enough - we can just handle this specific case then. >> I'd suggest a single reset_selinux_config() or similar function added to >> src/selinux_config.c that does the fini_ and init_ calls internally, and >> then call that single function from load policy. New simplified patch to reset the selinux_config. Acked-by: Stephen Smalley <sd...@ty...> Modified Paths: -------------- trunk/libselinux/src/load_policy.c trunk/libselinux/src/selinux_config.c trunk/libselinux/src/selinux_internal.h Modified: trunk/libselinux/src/load_policy.c =================================================================== --- trunk/libselinux/src/load_policy.c 2008-02-28 15:40:04 UTC (rev 2820) +++ trunk/libselinux/src/load_policy.c 2008-02-28 20:38:11 UTC (rev 2821) @@ -309,6 +309,13 @@ char *buf; /* + * Reread the selinux configuration in case it has changed. + * Example: Caller has chroot'd and is now loading policy from + * chroot'd environment. + */ + reset_selinux_config(); + + /* * Get desired mode (disabled, permissive, enforcing) from * /etc/selinux/config. */ Modified: trunk/libselinux/src/selinux_config.c =================================================================== --- trunk/libselinux/src/selinux_config.c 2008-02-28 15:40:04 UTC (rev 2820) +++ trunk/libselinux/src/selinux_config.c 2008-02-28 20:38:11 UTC (rev 2821) @@ -223,6 +223,12 @@ selinux_policytype = NULL; } +void reset_selinux_config(void) +{ + fini_selinux_policyroot(); + init_selinux_config(); +} + static const char *get_path(int idx) { return file_paths[idx]; Modified: trunk/libselinux/src/selinux_internal.h =================================================================== --- trunk/libselinux/src/selinux_internal.h 2008-02-28 15:40:04 UTC (rev 2820) +++ trunk/libselinux/src/selinux_internal.h 2008-02-28 20:38:11 UTC (rev 2821) @@ -80,6 +80,7 @@ hidden_proto(security_get_initial_context); hidden_proto(security_get_initial_context_raw); +extern void reset_selinux_config(void) hidden; extern int load_setlocaldefs hidden; extern int require_seusers hidden; extern int selinux_page_size hidden; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2008-04-18 13:57:46
|
Revision: 2861 http://selinux.svn.sourceforge.net/selinux/?rev=2861&view=rev Author: ssmalley Date: 2008-04-18 06:47:18 -0700 (Fri, 18 Apr 2008) Log Message: ----------- Author: Eamon Walsh Email: ew...@ty... Subject: libselinux/matchpathcon has a memory leak Date: Fri, 14 Mar 2008 15:27:11 -0400 Here is a new version of the patch. The clearing out of the data instead of freeing it is a leftover from when that was a global variable. That was the cause of the leak I thought was the result of a missing matchpathcon_fini(). Signed-off-by: Eamon Walsh <ew...@ty...> Acked-by: Stephen Smalley <sd...@ty...> Modified Paths: -------------- trunk/libselinux/src/label.c trunk/libselinux/src/label_file.c Modified: trunk/libselinux/src/label.c =================================================================== --- trunk/libselinux/src/label.c 2008-03-31 14:22:40 UTC (rev 2860) +++ trunk/libselinux/src/label.c 2008-04-18 13:47:18 UTC (rev 2861) @@ -95,7 +95,7 @@ if (compat_validate(rec, lr, "file_contexts", 0)) return NULL; - if (translating && + if (translating && !lr->ctx_trans && selinux_raw_to_trans_context(lr->ctx_raw, &lr->ctx_trans)) return NULL; Modified: trunk/libselinux/src/label_file.c =================================================================== --- trunk/libselinux/src/label_file.c 2008-03-31 14:22:40 UTC (rev 2860) +++ trunk/libselinux/src/label_file.c 2008-04-18 13:47:18 UTC (rev 2861) @@ -562,7 +562,7 @@ if (data->stem_arr) free(data->stem_arr); - memset(data, 0, sizeof(*data)); + free(data); } static struct selabel_lookup_rec *lookup(struct selabel_handle *rec, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2008-06-11 18:07:34
|
Revision: 2906 http://selinux.svn.sourceforge.net/selinux/?rev=2906&view=rev Author: ssmalley Date: 2008-06-11 11:07:30 -0700 (Wed, 11 Jun 2008) Log Message: ----------- Author: Daniel J Walsh Email: dw...@re... Subject: libselinux patch to add interfaces in avc.h to python bindings Date: Wed, 11 Jun 2008 12:43:20 -0400 Modified Paths: -------------- trunk/libselinux/src/selinuxswig.i trunk/libselinux/src/selinuxswig_python.i Modified: trunk/libselinux/src/selinuxswig.i =================================================================== --- trunk/libselinux/src/selinuxswig.i 2008-06-11 12:09:31 UTC (rev 2905) +++ trunk/libselinux/src/selinuxswig.i 2008-06-11 18:07:30 UTC (rev 2906) @@ -5,6 +5,7 @@ %module selinux %{ #include "selinux/selinux.h" + #include "../include/selinux/avc.h" #include "../include/selinux/selinux.h" #include "../include/selinux/get_default_type.h" #include "../include/selinux/get_context_list.h" @@ -47,6 +48,10 @@ %ignore set_matchpathcon_invalidcon; %ignore set_matchpathcon_canoncon; +%ignore avc_add_callback; + %include "../include/selinux/selinux.h" +%include "../include/selinux/avc.h" %include "../include/selinux/get_default_type.h" %include "../include/selinux/get_context_list.h" + Modified: trunk/libselinux/src/selinuxswig_python.i =================================================================== --- trunk/libselinux/src/selinuxswig_python.i 2008-06-11 12:09:31 UTC (rev 2905) +++ trunk/libselinux/src/selinuxswig_python.i 2008-06-11 18:07:30 UTC (rev 2906) @@ -16,6 +16,20 @@ $result = SWIG_Python_AppendOutput($result, list); } +/* return a sid along with the result */ +%typemap(argout) (security_id_t * sid) { + if (*$1) { + %append_output(SWIG_NewPointerObj(*$1, $descriptor(security_id_t), 0)); + } else { + Py_INCREF(Py_None); + %append_output(Py_None); + } +} + +%typemap(in,numinputs=0) security_id_t *(security_id_t temp) { + $1 = &temp; +} + /* Makes security_compute_user() return a Python list of contexts */ %typemap(argout) (security_context_t **con) { PyObject* plist; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ssm...@us...> - 2008-06-11 18:09:13
|
Revision: 2907 http://selinux.svn.sourceforge.net/selinux/?rev=2907&view=rev Author: ssmalley Date: 2008-06-11 11:09:03 -0700 (Wed, 11 Jun 2008) Log Message: ----------- make pywrap Modified Paths: -------------- trunk/libselinux/src/selinux.py trunk/libselinux/src/selinuxswig_wrap.c Modified: trunk/libselinux/src/selinux.py =================================================================== --- trunk/libselinux/src/selinux.py 2008-06-11 18:07:30 UTC (rev 2906) +++ trunk/libselinux/src/selinux.py 2008-06-11 18:09:03 UTC (rev 2907) @@ -300,6 +300,204 @@ selinux_file_context_cmp = _selinux.selinux_file_context_cmp selinux_file_context_verify = _selinux.selinux_file_context_verify selinux_lsetfilecon_default = _selinux.selinux_lsetfilecon_default +class security_id(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, security_id, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, security_id, name) + __repr__ = _swig_repr + __swig_setmethods__["ctx"] = _selinux.security_id_ctx_set + __swig_getmethods__["ctx"] = _selinux.security_id_ctx_get + if _newclass:ctx = _swig_property(_selinux.security_id_ctx_get, _selinux.security_id_ctx_set) + __swig_setmethods__["refcnt"] = _selinux.security_id_refcnt_set + __swig_getmethods__["refcnt"] = _selinux.security_id_refcnt_get + if _newclass:refcnt = _swig_property(_selinux.security_id_refcnt_get, _selinux.security_id_refcnt_set) + def __init__(self, *args): + this = _selinux.new_security_id(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _selinux.delete_security_id + __del__ = lambda self : None; +security_id_swigregister = _selinux.security_id_swigregister +security_id_swigregister(security_id) + +avc_sid_to_context = _selinux.avc_sid_to_context +avc_sid_to_context_raw = _selinux.avc_sid_to_context_raw +avc_context_to_sid = _selinux.avc_context_to_sid +avc_context_to_sid_raw = _selinux.avc_context_to_sid_raw +sidget = _selinux.sidget +sidput = _selinux.sidput +avc_get_initial_sid = _selinux.avc_get_initial_sid +class avc_entry_ref(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, avc_entry_ref, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, avc_entry_ref, name) + __repr__ = _swig_repr + __swig_setmethods__["ae"] = _selinux.avc_entry_ref_ae_set + __swig_getmethods__["ae"] = _selinux.avc_entry_ref_ae_get + if _newclass:ae = _swig_property(_selinux.avc_entry_ref_ae_get, _selinux.avc_entry_ref_ae_set) + def __init__(self, *args): + this = _selinux.new_avc_entry_ref(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _selinux.delete_avc_entry_ref + __del__ = lambda self : None; +avc_entry_ref_swigregister = _selinux.avc_entry_ref_swigregister +avc_entry_ref_swigregister(avc_entry_ref) + +class avc_memory_callback(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, avc_memory_callback, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, avc_memory_callback, name) + __repr__ = _swig_repr + __swig_setmethods__["func_malloc"] = _selinux.avc_memory_callback_func_malloc_set + __swig_getmethods__["func_malloc"] = _selinux.avc_memory_callback_func_malloc_get + if _newclass:func_malloc = _swig_property(_selinux.avc_memory_callback_func_malloc_get, _selinux.avc_memory_callback_func_malloc_set) + __swig_setmethods__["func_free"] = _selinux.avc_memory_callback_func_free_set + __swig_getmethods__["func_free"] = _selinux.avc_memory_callback_func_free_get + if _newclass:func_free = _swig_property(_selinux.avc_memory_callback_func_free_get, _selinux.avc_memory_callback_func_free_set) + def __init__(self, *args): + this = _selinux.new_avc_memory_callback(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _selinux.delete_avc_memory_callback + __del__ = lambda self : None; +avc_memory_callback_swigregister = _selinux.avc_memory_callback_swigregister +avc_memory_callback_swigregister(avc_memory_callback) + +class avc_log_callback(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, avc_log_callback, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, avc_log_callback, name) + __repr__ = _swig_repr + __swig_setmethods__["func_log"] = _selinux.avc_log_callback_func_log_set + __swig_getmethods__["func_log"] = _selinux.avc_log_callback_func_log_get + if _newclass:func_log = _swig_property(_selinux.avc_log_callback_func_log_get, _selinux.avc_log_callback_func_log_set) + __swig_setmethods__["func_audit"] = _selinux.avc_log_callback_func_audit_set + __swig_getmethods__["func_audit"] = _selinux.avc_log_callback_func_audit_get + if _newclass:func_audit = _swig_property(_selinux.avc_log_callback_func_audit_get, _selinux.avc_log_callback_func_audit_set) + def __init__(self, *args): + this = _selinux.new_avc_log_callback(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _selinux.delete_avc_log_callback + __del__ = lambda self : None; +avc_log_callback_swigregister = _selinux.avc_log_callback_swigregister +avc_log_callback_swigregister(avc_log_callback) + +class avc_thread_callback(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, avc_thread_callback, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, avc_thread_callback, name) + __repr__ = _swig_repr + __swig_setmethods__["func_create_thread"] = _selinux.avc_thread_callback_func_create_thread_set + __swig_getmethods__["func_create_thread"] = _selinux.avc_thread_callback_func_create_thread_get + if _newclass:func_create_thread = _swig_property(_selinux.avc_thread_callback_func_create_thread_get, _selinux.avc_thread_callback_func_create_thread_set) + __swig_setmethods__["func_stop_thread"] = _selinux.avc_thread_callback_func_stop_thread_set + __swig_getmethods__["func_stop_thread"] = _selinux.avc_thread_callback_func_stop_thread_get + if _newclass:func_stop_thread = _swig_property(_selinux.avc_thread_callback_func_stop_thread_get, _selinux.avc_thread_callback_func_stop_thread_set) + def __init__(self, *args): + this = _selinux.new_avc_thread_callback(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _selinux.delete_avc_thread_callback + __del__ = lambda self : None; +avc_thread_callback_swigregister = _selinux.avc_thread_callback_swigregister +avc_thread_callback_swigregister(avc_thread_callback) + +class avc_lock_callback(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, avc_lock_callback, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, avc_lock_callback, name) + __repr__ = _swig_repr + __swig_setmethods__["func_alloc_lock"] = _selinux.avc_lock_callback_func_alloc_lock_set + __swig_getmethods__["func_alloc_lock"] = _selinux.avc_lock_callback_func_alloc_lock_get + if _newclass:func_alloc_lock = _swig_property(_selinux.avc_lock_callback_func_alloc_lock_get, _selinux.avc_lock_callback_func_alloc_lock_set) + __swig_setmethods__["func_get_lock"] = _selinux.avc_lock_callback_func_get_lock_set + __swig_getmethods__["func_get_lock"] = _selinux.avc_lock_callback_func_get_lock_get + if _newclass:func_get_lock = _swig_property(_selinux.avc_lock_callback_func_get_lock_get, _selinux.avc_lock_callback_func_get_lock_set) + __swig_setmethods__["func_release_lock"] = _selinux.avc_lock_callback_func_release_lock_set + __swig_getmethods__["func_release_lock"] = _selinux.avc_lock_callback_func_release_lock_get + if _newclass:func_release_lock = _swig_property(_selinux.avc_lock_callback_func_release_lock_get, _selinux.avc_lock_callback_func_release_lock_set) + __swig_setmethods__["func_free_lock"] = _selinux.avc_lock_callback_func_free_lock_set + __swig_getmethods__["func_free_lock"] = _selinux.avc_lock_callback_func_free_lock_get + if _newclass:func_free_lock = _swig_property(_selinux.avc_lock_callback_func_free_lock_get, _selinux.avc_lock_callback_func_free_lock_set) + def __init__(self, *args): + this = _selinux.new_avc_lock_callback(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _selinux.delete_avc_lock_callback + __del__ = lambda self : None; +avc_lock_callback_swigregister = _selinux.avc_lock_callback_swigregister +avc_lock_callback_swigregister(avc_lock_callback) + +AVC_OPT_UNUSED = _selinux.AVC_OPT_UNUSED +AVC_OPT_SETENFORCE = _selinux.AVC_OPT_SETENFORCE +avc_init = _selinux.avc_init +avc_open = _selinux.avc_open +avc_cleanup = _selinux.avc_cleanup +avc_reset = _selinux.avc_reset +avc_destroy = _selinux.avc_destroy +avc_has_perm_noaudit = _selinux.avc_has_perm_noaudit +avc_has_perm = _selinux.avc_has_perm +avc_audit = _selinux.avc_audit +avc_compute_create = _selinux.avc_compute_create +avc_compute_member = _selinux.avc_compute_member +AVC_CALLBACK_GRANT = _selinux.AVC_CALLBACK_GRANT +AVC_CALLBACK_TRY_REVOKE = _selinux.AVC_CALLBACK_TRY_REVOKE +AVC_CALLBACK_REVOKE = _selinux.AVC_CALLBACK_REVOKE +AVC_CALLBACK_RESET = _selinux.AVC_CALLBACK_RESET +AVC_CALLBACK_AUDITALLOW_ENABLE = _selinux.AVC_CALLBACK_AUDITALLOW_ENABLE +AVC_CALLBACK_AUDITALLOW_DISABLE = _selinux.AVC_CALLBACK_AUDITALLOW_DISABLE +AVC_CALLBACK_AUDITDENY_ENABLE = _selinux.AVC_CALLBACK_AUDITDENY_ENABLE +AVC_CALLBACK_AUDITDENY_DISABLE = _selinux.AVC_CALLBACK_AUDITDENY_DISABLE +AVC_CACHE_STATS = _selinux.AVC_CACHE_STATS +class avc_cache_stats(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, avc_cache_stats, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, avc_cache_stats, name) + __repr__ = _swig_repr + __swig_setmethods__["entry_lookups"] = _selinux.avc_cache_stats_entry_lookups_set + __swig_getmethods__["entry_lookups"] = _selinux.avc_cache_stats_entry_lookups_get + if _newclass:entry_lookups = _swig_property(_selinux.avc_cache_stats_entry_lookups_get, _selinux.avc_cache_stats_entry_lookups_set) + __swig_setmethods__["entry_hits"] = _selinux.avc_cache_stats_entry_hits_set + __swig_getmethods__["entry_hits"] = _selinux.avc_cache_stats_entry_hits_get + if _newclass:entry_hits = _swig_property(_selinux.avc_cache_stats_entry_hits_get, _selinux.avc_cache_stats_entry_hits_set) + __swig_setmethods__["entry_misses"] = _selinux.avc_cache_stats_entry_misses_set + __swig_getmethods__["entry_misses"] = _selinux.avc_cache_stats_entry_misses_get + if _newclass:entry_misses = _swig_property(_selinux.avc_cache_stats_entry_misses_get, _selinux.avc_cache_stats_entry_misses_set) + __swig_setmethods__["entry_discards"] = _selinux.avc_cache_stats_entry_discards_set + __swig_getmethods__["entry_discards"] = _selinux.avc_cache_stats_entry_discards_get + if _newclass:entry_discards = _swig_property(_selinux.avc_cache_stats_entry_discards_get, _selinux.avc_cache_stats_entry_discards_set) + __swig_setmethods__["cav_lookups"] = _selinux.avc_cache_stats_cav_lookups_set + __swig_getmethods__["cav_lookups"] = _selinux.avc_cache_stats_cav_lookups_get + if _newclass:cav_lookups = _swig_property(_selinux.avc_cache_stats_cav_lookups_get, _selinux.avc_cache_stats_cav_lookups_set) + __swig_setmethods__["cav_hits"] = _selinux.avc_cache_stats_cav_hits_set + __swig_getmethods__["cav_hits"] = _selinux.avc_cache_stats_cav_hits_get + if _newclass:cav_hits = _swig_property(_selinux.avc_cache_stats_cav_hits_get, _selinux.avc_cache_stats_cav_hits_set) + __swig_setmethods__["cav_probes"] = _selinux.avc_cache_stats_cav_probes_set + __swig_getmethods__["cav_probes"] = _selinux.avc_cache_stats_cav_probes_get + if _newclass:cav_probes = _swig_property(_selinux.avc_cache_stats_cav_probes_get, _selinux.avc_cache_stats_cav_probes_set) + __swig_setmethods__["cav_misses"] = _selinux.avc_cache_stats_cav_misses_set + __swig_getmethods__["cav_misses"] = _selinux.avc_cache_stats_cav_misses_get + if _newclass:cav_misses = _swig_property(_selinux.avc_cache_stats_cav_misses_get, _selinux.avc_cache_stats_cav_misses_set) + def __init__(self, *args): + this = _selinux.new_avc_cache_stats(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _selinux.delete_avc_cache_stats + __del__ = lambda self : None; +avc_cache_stats_swigregister = _selinux.avc_cache_stats_swigregister +avc_cache_stats_swigregister(avc_cache_stats) + +avc_av_stats = _selinux.avc_av_stats +avc_sid_stats = _selinux.avc_sid_stats selinux_default_type_path = _selinux.selinux_default_type_path get_default_type = _selinux.get_default_type SELINUX_DEFAULTUSER = _selinux.SELINUX_DEFAULTUSER Modified: trunk/libselinux/src/selinuxswig_wrap.c =================================================================== --- trunk/libselinux/src/selinuxswig_wrap.c 2008-06-11 18:07:30 UTC (rev 2906) +++ trunk/libselinux/src/selinuxswig_wrap.c 2008-06-11 18:09:03 UTC (rev 2907) @@ -2458,21 +2458,36 @@ #define SWIGTYPE_p_SELboolean swig_types[0] #define SWIGTYPE_p_av_decision swig_types[1] -#define SWIGTYPE_p_char swig_types[2] -#define SWIGTYPE_p_f_int_p_q_const__char_v_______int swig_types[3] -#define SWIGTYPE_p_f_p_p_char__int swig_types[4] -#define SWIGTYPE_p_f_p_void_unsigned_short_p_char_size_t__int swig_types[5] -#define SWIGTYPE_p_ino_t swig_types[6] -#define SWIGTYPE_p_int swig_types[7] -#define SWIGTYPE_p_p_char swig_types[8] -#define SWIGTYPE_p_p_p_char swig_types[9] -#define SWIGTYPE_p_security_class_mapping swig_types[10] -#define SWIGTYPE_p_selinux_callback swig_types[11] -#define SWIGTYPE_p_selinux_opt swig_types[12] -#define SWIGTYPE_p_unsigned_int swig_types[13] -#define SWIGTYPE_p_unsigned_short swig_types[14] -static swig_type_info *swig_types[16]; -static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0}; +#define SWIGTYPE_p_avc_cache_stats swig_types[2] +#define SWIGTYPE_p_avc_entry swig_types[3] +#define SWIGTYPE_p_avc_entry_ref swig_types[4] +#define SWIGTYPE_p_avc_lock_callback swig_types[5] +#define SWIGTYPE_p_avc_log_callback swig_types[6] +#define SWIGTYPE_p_avc_memory_callback swig_types[7] +#define SWIGTYPE_p_avc_thread_callback swig_types[8] +#define SWIGTYPE_p_char swig_types[9] +#define SWIGTYPE_p_f_int_p_q_const__char_v_______int swig_types[10] +#define SWIGTYPE_p_f_p_f_void__void__p_void swig_types[11] +#define SWIGTYPE_p_f_p_p_char__int swig_types[12] +#define SWIGTYPE_p_f_p_q_const__char_v_______void swig_types[13] +#define SWIGTYPE_p_f_p_void__void swig_types[14] +#define SWIGTYPE_p_f_p_void_unsigned_short_p_char_size_t__int swig_types[15] +#define SWIGTYPE_p_f_p_void_unsigned_short_p_char_size_t__void swig_types[16] +#define SWIGTYPE_p_f_size_t__p_void swig_types[17] +#define SWIGTYPE_p_f_void__p_void swig_types[18] +#define SWIGTYPE_p_ino_t swig_types[19] +#define SWIGTYPE_p_int swig_types[20] +#define SWIGTYPE_p_p_char swig_types[21] +#define SWIGTYPE_p_p_p_char swig_types[22] +#define SWIGTYPE_p_p_security_id swig_types[23] +#define SWIGTYPE_p_security_class_mapping swig_types[24] +#define SWIGTYPE_p_security_id swig_types[25] +#define SWIGTYPE_p_selinux_callback swig_types[26] +#define SWIGTYPE_p_selinux_opt swig_types[27] +#define SWIGTYPE_p_unsigned_int swig_types[28] +#define SWIGTYPE_p_unsigned_short swig_types[29] +static swig_type_info *swig_types[31]; +static swig_module_info swig_module = {swig_types, 30, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -2503,6 +2518,7 @@ #include "selinux/selinux.h" + #include "../include/selinux/avc.h" #include "../include/selinux/selinux.h" #include "../include/selinux/get_default_type.h" #include "../include/selinux/get_context_list.h" @@ -7461,6 +7477,2083 @@ } +SWIGINTERN PyObject *_wrap_security_id_ctx_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct security_id *arg1 = (struct security_id *) 0 ; + security_context_t arg2 = (security_context_t) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:security_id_ctx_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_id, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "security_id_ctx_set" "', argument " "1"" of type '" "struct security_id *""'"); + } + arg1 = (struct security_id *)(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "security_id_ctx_set" "', argument " "2"" of type '" "security_context_t""'"); + } + arg2 = (security_context_t)(buf2); + if (arg1->ctx) free((char*)arg1->ctx); + if (arg2) { + size_t size = strlen((const char *)(arg2)) + 1; + arg1->ctx = (security_context_t)(char *)memcpy((char *)malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size)); + } else { + arg1->ctx = 0; + } + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_security_id_ctx_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct security_id *arg1 = (struct security_id *) 0 ; + security_context_t result; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:security_id_ctx_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_id, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "security_id_ctx_get" "', argument " "1"" of type '" "struct security_id *""'"); + } + arg1 = (struct security_id *)(argp1); + result = (security_context_t) ((arg1)->ctx); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_security_id_refcnt_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct security_id *arg1 = (struct security_id *) 0 ; + unsigned int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:security_id_refcnt_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_id, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "security_id_refcnt_set" "', argument " "1"" of type '" "struct security_id *""'"); + } + arg1 = (struct security_id *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "security_id_refcnt_set" "', argument " "2"" of type '" "unsigned int""'"); + } + arg2 = (unsigned int)(val2); + if (arg1) (arg1)->refcnt = arg2; + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_security_id_refcnt_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct security_id *arg1 = (struct security_id *) 0 ; + unsigned int result; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:security_id_refcnt_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_id, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "security_id_refcnt_get" "', argument " "1"" of type '" "struct security_id *""'"); + } + arg1 = (struct security_id *)(argp1); + result = (unsigned int) ((arg1)->refcnt); + resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_security_id(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct security_id *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_security_id")) SWIG_fail; + result = (struct security_id *)(struct security_id *) calloc(1, sizeof(struct security_id)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_security_id, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_security_id(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct security_id *arg1 = (struct security_id *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_security_id",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_id, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_security_id" "', argument " "1"" of type '" "struct security_id *""'"); + } + arg1 = (struct security_id *)(argp1); + free((char *) arg1); + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *security_id_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_security_id, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_avc_sid_to_context(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_id_t arg1 = (security_id_t) 0 ; + security_context_t *arg2 = (security_context_t *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + security_context_t temp2 = 0 ; + PyObject * obj0 = 0 ; + + arg2 = &temp2; + if (!PyArg_ParseTuple(args,(char *)"O:avc_sid_to_context",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_id, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_sid_to_context" "', argument " "1"" of type '" "security_id_t""'"); + } + arg1 = (security_id_t)(argp1); + result = (int)avc_sid_to_context(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + if (*arg2) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); + freecon(*arg2); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_sid_to_context_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_id_t arg1 = (security_id_t) 0 ; + security_context_t *arg2 = (security_context_t *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + security_context_t temp2 = 0 ; + PyObject * obj0 = 0 ; + + arg2 = &temp2; + if (!PyArg_ParseTuple(args,(char *)"O:avc_sid_to_context_raw",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_id, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_sid_to_context_raw" "', argument " "1"" of type '" "security_id_t""'"); + } + arg1 = (security_id_t)(argp1); + result = (int)avc_sid_to_context_raw(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + if (*arg2) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); + freecon(*arg2); + } + else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_context_to_sid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 = (security_context_t) 0 ; + security_id_t *arg2 = (security_id_t *) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + security_id_t temp2 ; + PyObject * obj0 = 0 ; + + { + arg2 = &temp2; + } + if (!PyArg_ParseTuple(args,(char *)"O:avc_context_to_sid",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_context_to_sid" "', argument " "1"" of type '" "security_context_t""'"); + } + arg1 = (security_context_t)(buf1); + result = (int)avc_context_to_sid(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + { + if (*arg2) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj(*arg2, SWIGTYPE_p_security_id, 0)); + } else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_context_to_sid_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_context_t arg1 = (security_context_t) 0 ; + security_id_t *arg2 = (security_id_t *) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + security_id_t temp2 ; + PyObject * obj0 = 0 ; + + { + arg2 = &temp2; + } + if (!PyArg_ParseTuple(args,(char *)"O:avc_context_to_sid_raw",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_context_to_sid_raw" "', argument " "1"" of type '" "security_context_t""'"); + } + arg1 = (security_context_t)(buf1); + result = (int)avc_context_to_sid_raw(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + { + if (*arg2) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj(*arg2, SWIGTYPE_p_security_id, 0)); + } else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sidget(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_id_t arg1 = (security_id_t) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:sidget",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_id, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sidget" "', argument " "1"" of type '" "security_id_t""'"); + } + arg1 = (security_id_t)(argp1); + result = (int)sidget(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sidput(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + security_id_t arg1 = (security_id_t) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:sidput",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_id, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sidput" "', argument " "1"" of type '" "security_id_t""'"); + } + arg1 = (security_id_t)(argp1); + result = (int)sidput(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_get_initial_sid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + security_id_t *arg2 = (security_id_t *) 0 ; + int result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + security_id_t temp2 ; + PyObject * obj0 = 0 ; + + { + arg2 = &temp2; + } + if (!PyArg_ParseTuple(args,(char *)"O:avc_get_initial_sid",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_get_initial_sid" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + result = (int)avc_get_initial_sid((char const *)arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + { + if (*arg2) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj(*arg2, SWIGTYPE_p_security_id, 0)); + } else { + Py_INCREF(Py_None); + resultobj = SWIG_Python_AppendOutput(resultobj, Py_None); + } + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_entry_ref_ae_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_entry_ref *arg1 = (struct avc_entry_ref *) 0 ; + struct avc_entry *arg2 = (struct avc_entry *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:avc_entry_ref_ae_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_entry_ref, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_entry_ref_ae_set" "', argument " "1"" of type '" "struct avc_entry_ref *""'"); + } + arg1 = (struct avc_entry_ref *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_avc_entry, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "avc_entry_ref_ae_set" "', argument " "2"" of type '" "struct avc_entry *""'"); + } + arg2 = (struct avc_entry *)(argp2); + if (arg1) (arg1)->ae = arg2; + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_entry_ref_ae_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_entry_ref *arg1 = (struct avc_entry_ref *) 0 ; + struct avc_entry *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:avc_entry_ref_ae_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_entry_ref, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_entry_ref_ae_get" "', argument " "1"" of type '" "struct avc_entry_ref *""'"); + } + arg1 = (struct avc_entry_ref *)(argp1); + result = (struct avc_entry *) ((arg1)->ae); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_avc_entry, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_avc_entry_ref(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_entry_ref *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_avc_entry_ref")) SWIG_fail; + result = (struct avc_entry_ref *)(struct avc_entry_ref *) calloc(1, sizeof(struct avc_entry_ref)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_avc_entry_ref, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_avc_entry_ref(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_entry_ref *arg1 = (struct avc_entry_ref *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_avc_entry_ref",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_entry_ref, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_avc_entry_ref" "', argument " "1"" of type '" "struct avc_entry_ref *""'"); + } + arg1 = (struct avc_entry_ref *)(argp1); + free((char *) arg1); + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *avc_entry_ref_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_avc_entry_ref, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_avc_memory_callback_func_malloc_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_memory_callback *arg1 = (struct avc_memory_callback *) 0 ; + void *(*arg2)(size_t) = (void *(*)(size_t)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:avc_memory_callback_func_malloc_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_memory_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_memory_callback_func_malloc_set" "', argument " "1"" of type '" "struct avc_memory_callback *""'"); + } + arg1 = (struct avc_memory_callback *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_size_t__p_void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "avc_memory_callback_func_malloc_set" "', argument " "2"" of type '" "void *(*)(size_t)""'"); + } + } + if (arg1) (arg1)->func_malloc = arg2; + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_memory_callback_func_malloc_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_memory_callback *arg1 = (struct avc_memory_callback *) 0 ; + void *(*result)(size_t) = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:avc_memory_callback_func_malloc_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_memory_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_memory_callback_func_malloc_get" "', argument " "1"" of type '" "struct avc_memory_callback *""'"); + } + arg1 = (struct avc_memory_callback *)(argp1); + result = (void *(*)(size_t)) ((arg1)->func_malloc); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_size_t__p_void); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_memory_callback_func_free_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_memory_callback *arg1 = (struct avc_memory_callback *) 0 ; + void (*arg2)(void *) = (void (*)(void *)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:avc_memory_callback_func_free_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_memory_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_memory_callback_func_free_set" "', argument " "1"" of type '" "struct avc_memory_callback *""'"); + } + arg1 = (struct avc_memory_callback *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_p_void__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "avc_memory_callback_func_free_set" "', argument " "2"" of type '" "void (*)(void *)""'"); + } + } + if (arg1) (arg1)->func_free = arg2; + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_memory_callback_func_free_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_memory_callback *arg1 = (struct avc_memory_callback *) 0 ; + void (*result)(void *) = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:avc_memory_callback_func_free_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_memory_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_memory_callback_func_free_get" "', argument " "1"" of type '" "struct avc_memory_callback *""'"); + } + arg1 = (struct avc_memory_callback *)(argp1); + result = (void (*)(void *)) ((arg1)->func_free); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_void__void); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_avc_memory_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_memory_callback *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_avc_memory_callback")) SWIG_fail; + result = (struct avc_memory_callback *)(struct avc_memory_callback *) calloc(1, sizeof(struct avc_memory_callback)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_avc_memory_callback, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_avc_memory_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_memory_callback *arg1 = (struct avc_memory_callback *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_avc_memory_callback",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_memory_callback, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_avc_memory_callback" "', argument " "1"" of type '" "struct avc_memory_callback *""'"); + } + arg1 = (struct avc_memory_callback *)(argp1); + free((char *) arg1); + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *avc_memory_callback_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_avc_memory_callback, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_avc_log_callback_func_log_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_log_callback *arg1 = (struct avc_log_callback *) 0 ; + void (*arg2)(char const *,...) = (void (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:avc_log_callback_func_log_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_log_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_log_callback_func_log_set" "', argument " "1"" of type '" "struct avc_log_callback *""'"); + } + arg1 = (struct avc_log_callback *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_p_q_const__char_v_______void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "avc_log_callback_func_log_set" "', argument " "2"" of type '" "void (*)(char const *,...)""'"); + } + } + if (arg1) (arg1)->func_log = arg2; + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_log_callback_func_log_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_log_callback *arg1 = (struct avc_log_callback *) 0 ; + void (*result)(char const *,...) = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:avc_log_callback_func_log_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_log_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_log_callback_func_log_get" "', argument " "1"" of type '" "struct avc_log_callback *""'"); + } + arg1 = (struct avc_log_callback *)(argp1); + result = (void (*)(char const *,...)) ((arg1)->func_log); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_q_const__char_v_______void); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_log_callback_func_audit_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_log_callback *arg1 = (struct avc_log_callback *) 0 ; + void (*arg2)(void *,security_class_t,char *,size_t) = (void (*)(void *,security_class_t,char *,size_t)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:avc_log_callback_func_audit_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_log_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_log_callback_func_audit_set" "', argument " "1"" of type '" "struct avc_log_callback *""'"); + } + arg1 = (struct avc_log_callback *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_p_void_unsigned_short_p_char_size_t__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "avc_log_callback_func_audit_set" "', argument " "2"" of type '" "void (*)(void *,security_class_t,char *,size_t)""'"); + } + } + if (arg1) (arg1)->func_audit = arg2; + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_log_callback_func_audit_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_log_callback *arg1 = (struct avc_log_callback *) 0 ; + void (*result)(void *,security_class_t,char *,size_t) = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:avc_log_callback_func_audit_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_log_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_log_callback_func_audit_get" "', argument " "1"" of type '" "struct avc_log_callback *""'"); + } + arg1 = (struct avc_log_callback *)(argp1); + result = (void (*)(void *,security_class_t,char *,size_t)) ((arg1)->func_audit); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_void_unsigned_short_p_char_size_t__void); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_avc_log_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_log_callback *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_avc_log_callback")) SWIG_fail; + result = (struct avc_log_callback *)(struct avc_log_callback *) calloc(1, sizeof(struct avc_log_callback)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_avc_log_callback, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_avc_log_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_log_callback *arg1 = (struct avc_log_callback *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_avc_log_callback",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_log_callback, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_avc_log_callback" "', argument " "1"" of type '" "struct avc_log_callback *""'"); + } + arg1 = (struct avc_log_callback *)(argp1); + free((char *) arg1); + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *avc_log_callback_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_avc_log_callback, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_avc_thread_callback_func_create_thread_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_thread_callback *arg1 = (struct avc_thread_callback *) 0 ; + void *(*arg2)(void (*)(void)) = (void *(*)(void (*)(void))) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:avc_thread_callback_func_create_thread_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_thread_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_thread_callback_func_create_thread_set" "', argument " "1"" of type '" "struct avc_thread_callback *""'"); + } + arg1 = (struct avc_thread_callback *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_p_f_void__void__p_void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "avc_thread_callback_func_create_thread_set" "', argument " "2"" of type '" "void *(*)(void (*)(void))""'"); + } + } + if (arg1) (arg1)->func_create_thread = arg2; + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_thread_callback_func_create_thread_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_thread_callback *arg1 = (struct avc_thread_callback *) 0 ; + void *(*result)(void (*)(void)) = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:avc_thread_callback_func_create_thread_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_thread_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_thread_callback_func_create_thread_get" "', argument " "1"" of type '" "struct avc_thread_callback *""'"); + } + arg1 = (struct avc_thread_callback *)(argp1); + result = (void *(*)(void (*)(void))) ((arg1)->func_create_thread); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_f_void__void__p_void); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_thread_callback_func_stop_thread_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_thread_callback *arg1 = (struct avc_thread_callback *) 0 ; + void (*arg2)(void *) = (void (*)(void *)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:avc_thread_callback_func_stop_thread_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_thread_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_thread_callback_func_stop_thread_set" "', argument " "1"" of type '" "struct avc_thread_callback *""'"); + } + arg1 = (struct avc_thread_callback *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_p_void__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "avc_thread_callback_func_stop_thread_set" "', argument " "2"" of type '" "void (*)(void *)""'"); + } + } + if (arg1) (arg1)->func_stop_thread = arg2; + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_thread_callback_func_stop_thread_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_thread_callback *arg1 = (struct avc_thread_callback *) 0 ; + void (*result)(void *) = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:avc_thread_callback_func_stop_thread_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_thread_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_thread_callback_func_stop_thread_get" "', argument " "1"" of type '" "struct avc_thread_callback *""'"); + } + arg1 = (struct avc_thread_callback *)(argp1); + result = (void (*)(void *)) ((arg1)->func_stop_thread); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_void__void); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_avc_thread_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_thread_callback *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_avc_thread_callback")) SWIG_fail; + result = (struct avc_thread_callback *)(struct avc_thread_callback *) calloc(1, sizeof(struct avc_thread_callback)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_avc_thread_callback, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_avc_thread_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_thread_callback *arg1 = (struct avc_thread_callback *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_avc_thread_callback",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_thread_callback, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_avc_thread_callback" "', argument " "1"" of type '" "struct avc_thread_callback *""'"); + } + arg1 = (struct avc_thread_callback *)(argp1); + free((char *) arg1); + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *avc_thread_callback_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_avc_thread_callback, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_avc_lock_callback_func_alloc_lock_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_lock_callback *arg1 = (struct avc_lock_callback *) 0 ; + void *(*arg2)(void) = (void *(*)(void)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:avc_lock_callback_func_alloc_lock_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_lock_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_lock_callback_func_alloc_lock_set" "', argument " "1"" of type '" "struct avc_lock_callback *""'"); + } + arg1 = (struct avc_lock_callback *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_void__p_void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "avc_lock_callback_func_alloc_lock_set" "', argument " "2"" of type '" "void *(*)(void)""'"); + } + } + if (arg1) (arg1)->func_alloc_lock = arg2; + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_lock_callback_func_alloc_lock_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_lock_callback *arg1 = (struct avc_lock_callback *) 0 ; + void *(*result)(void) = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:avc_lock_callback_func_alloc_lock_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_lock_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_lock_callback_func_alloc_lock_get" "', argument " "1"" of type '" "struct avc_lock_callback *""'"); + } + arg1 = (struct avc_lock_callback *)(argp1); + result = (void *(*)(void)) ((arg1)->func_alloc_lock); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_void__p_void); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_lock_callback_func_get_lock_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_lock_callback *arg1 = (struct avc_lock_callback *) 0 ; + void (*arg2)(void *) = (void (*)(void *)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:avc_lock_callback_func_get_lock_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_lock_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_lock_callback_func_get_lock_set" "', argument " "1"" of type '" "struct avc_lock_callback *""'"); + } + arg1 = (struct avc_lock_callback *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_p_void__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "avc_lock_callback_func_get_lock_set" "', argument " "2"" of type '" "void (*)(void *)""'"); + } + } + if (arg1) (arg1)->func_get_lock = arg2; + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_lock_callback_func_get_lock_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_lock_callback *arg1 = (struct avc_lock_callback *) 0 ; + void (*result)(void *) = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:avc_lock_callback_func_get_lock_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_lock_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_lock_callback_func_get_lock_get" "', argument " "1"" of type '" "struct avc_lock_callback *""'"); + } + arg1 = (struct avc_lock_callback *)(argp1); + result = (void (*)(void *)) ((arg1)->func_get_lock); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_void__void); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_lock_callback_func_release_lock_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_lock_callback *arg1 = (struct avc_lock_callback *) 0 ; + void (*arg2)(void *) = (void (*)(void *)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:avc_lock_callback_func_release_lock_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_lock_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_lock_callback_func_release_lock_set" "', argument " "1"" of type '" "struct avc_lock_callback *""'"); + } + arg1 = (struct avc_lock_callback *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_p_void__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "avc_lock_callback_func_release_lock_set" "', argument " "2"" of type '" "void (*)(void *)""'"); + } + } + if (arg1) (arg1)->func_release_lock = arg2; + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_lock_callback_func_release_lock_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_lock_callback *arg1 = (struct avc_lock_callback *) 0 ; + void (*result)(void *) = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:avc_lock_callback_func_release_lock_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_lock_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_lock_callback_func_release_lock_get" "', argument " "1"" of type '" "struct avc_lock_callback *""'"); + } + arg1 = (struct avc_lock_callback *)(argp1); + result = (void (*)(void *)) ((arg1)->func_release_lock); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_void__void); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_lock_callback_func_free_lock_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_lock_callback *arg1 = (struct avc_lock_callback *) 0 ; + void (*arg2)(void *) = (void (*)(void *)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:avc_lock_callback_func_free_lock_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_lock_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_lock_callback_func_free_lock_set" "', argument " "1"" of type '" "struct avc_lock_callback *""'"); + } + arg1 = (struct avc_lock_callback *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_p_void__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "avc_lock_callback_func_free_lock_set" "', argument " "2"" of type '" "void (*)(void *)""'"); + } + } + if (arg1) (arg1)->func_free_lock = arg2; + + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_avc_lock_callback_func_free_lock_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_lock_callback *arg1 = (struct avc_lock_callback *) 0 ; + void (*result)(void *) = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:avc_lock_callback_func_free_lock_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_lock_callback, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "avc_lock_callback_func_free_lock_get" "', argument " "1"" of type '" "struct avc_lock_callback *""'"); + } + arg1 = (struct avc_lock_callback *)(argp1); + result = (void (*)(void *)) ((arg1)->func_free_lock); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_void__void); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_avc_lock_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_lock_callback *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_avc_lock_callback")) SWIG_fail; + result = (struct avc_lock_callback *)(struct avc_lock_callback *) calloc(1, sizeof(struct avc_lock_callback)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_avc_lock_callback, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_avc_lock_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct avc_lock_callback *arg1 = (struct avc_lock_callback *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_avc_lock_callback",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_avc_lock_callback, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + ... [truncated message content] |