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] |