- Fix crash in python

This commit is contained in:
Daniel J Walsh 2009-04-02 13:36:47 +00:00
parent f6ba4d34de
commit 261c72abdb
2 changed files with 8 additions and 848 deletions

View File

@ -84,827 +84,6 @@ diff --exclude-from=exclude -N -u -r nsalibselinux/src/callbacks.c libselinux-2.
va_start(ap, fmt);
rc = vfprintf(stderr, fmt, ap);
va_end(ap);
diff --exclude-from=exclude -N -u -r nsalibselinux/src/d libselinux-2.0.79/src/d
--- nsalibselinux/src/d 1969-12-31 19:00:00.000000000 -0500
+++ libselinux-2.0.79/src/d 2009-03-27 11:32:04.000000000 -0400
@@ -0,0 +1,801 @@
+
+%exception is_selinux_enabled {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception is_selinux_mls_enabled {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getcon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getcon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception setcon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception setcon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getpidcon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getpidcon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getprevcon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getprevcon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getexeccon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getexeccon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception setexeccon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception setexeccon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getfscreatecon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getfscreatecon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception setfscreatecon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception setfscreatecon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getkeycreatecon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getkeycreatecon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception setkeycreatecon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception setkeycreatecon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getsockcreatecon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getsockcreatecon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception setsockcreatecon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception setsockcreatecon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getfilecon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getfilecon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception lgetfilecon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception lgetfilecon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception fgetfilecon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception fgetfilecon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception setfilecon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception setfilecon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception lsetfilecon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception lsetfilecon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception fsetfilecon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception fsetfilecon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getpeercon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getpeercon_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_compute_av {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_compute_av_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_compute_create {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_compute_create_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_compute_relabel {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_compute_relabel_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_compute_member {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_compute_member_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_compute_user {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_compute_user_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_load_policy {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_get_initial_context {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_get_initial_context_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception selinux_mkload_policy {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception selinux_init_load_policy {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_set_boolean_list {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_load_booleans {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_check_context {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_check_context_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_canonicalize_context {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_canonicalize_context_raw {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_getenforce {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_setenforce {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_disable {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_policyvers {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_get_boolean_names {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_get_boolean_pending {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_get_boolean_active {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_set_boolean {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_commit_booleans {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception security_av_string {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception matchpathcon_init {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception matchpathcon_init_prefix {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception matchpathcon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception matchpathcon_index {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception matchpathcon_filespec_add {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception matchmediacon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception selinux_getenforcemode {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception selinux_getpolicytype {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception selinux_check_passwd_access {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception checkPasswdAccess {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception selinux_check_securetty_context {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception rpm_execcon {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception is_context_customizable {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception selinux_trans_to_raw_context {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception selinux_raw_to_trans_context {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception selinux_raw_context_to_color {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getseuserbyname {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
+
+%exception getseuser {
+
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+
diff --exclude-from=exclude -N -u -r nsalibselinux/src/exception.h libselinux-2.0.79/src/exception.h
--- nsalibselinux/src/exception.h 1969-12-31 19:00:00.000000000 -0500
+++ libselinux-2.0.79/src/exception.h 2009-03-27 11:32:14.000000000 -0400
@@ -0,0 +1,12 @@
+function except() {
+echo "
+%exception $1 {
+ $action
+ if (result < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+}
+"
+}
+for i in `grep "extern *int" ../include/selinux/selinux.h | awk '{ print $3 }' | cut -d '(' -f 1`; do except $i ; done
diff --exclude-from=exclude -N -u -r nsalibselinux/src/exception.sh libselinux-2.0.79/src/exception.sh
--- nsalibselinux/src/exception.sh 1969-12-31 19:00:00.000000000 -0500
+++ libselinux-2.0.79/src/exception.sh 2009-03-27 14:20:10.000000000 -0400
@ -3404,7 +2583,7 @@ diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinux.py libselinux-2.0
Binary files nsalibselinux/src/selinux.pyc and libselinux-2.0.79/src/selinux.pyc differ
diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinuxswig.i libselinux-2.0.79/src/selinuxswig.i
--- nsalibselinux/src/selinuxswig.i 2009-03-12 08:48:48.000000000 -0400
+++ libselinux-2.0.79/src/selinuxswig.i 2009-03-29 11:15:11.000000000 -0400
+++ libselinux-2.0.79/src/selinuxswig.i 2009-04-02 09:35:01.000000000 -0400
@@ -4,11 +4,14 @@
%module selinux
@ -3423,24 +2602,7 @@ diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinuxswig.i libselinux-
%}
%apply int *OUTPUT { int *enforce };
%apply int *OUTPUT { size_t * };
@@ -47,7 +50,15 @@
%ignore set_matchpathcon_printf;
%ignore set_matchpathcon_invalidcon;
%ignore set_matchpathcon_canoncon;
-
+%ignore set_selinuxmnt;
+%ignore avc_memory_callback;
+%ignore avc_log_callback;
+%ignore avc_thread_callback;
+%ignore avc_lock_callback;
+%ignore selinux_callback;
+%ignore selinux_get_callback;
+%ignore selinux_set_callback;
+%ignore print_access_vector;
%ignore avc_add_callback;
/* Ignore netlink stuff for now */
@@ -55,8 +66,11 @@
@@ -55,8 +58,11 @@
%ignore avc_netlink_release_fd;
%ignore avc_netlink_check_nb;
@ -3457,7 +2619,7 @@ diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinuxswig.i libselinux-
+%include "../include/selinux/selinux.h"
diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinuxswig_python.i libselinux-2.0.79/src/selinuxswig_python.i
--- nsalibselinux/src/selinuxswig_python.i 2009-03-06 14:41:45.000000000 -0500
+++ libselinux-2.0.79/src/selinuxswig_python.i 2009-03-27 14:07:34.000000000 -0400
+++ libselinux-2.0.79/src/selinuxswig_python.i 2009-04-01 10:14:50.000000000 -0400
@@ -21,6 +21,15 @@
map(restorecon, [os.path.join(dirname, fname)
for fname in fnames]), None)
@ -3474,17 +2636,12 @@ diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinuxswig_python.i libs
%}
/* security_get_boolean_names() typemap */
@@ -150,4 +159,10 @@
@@ -150,4 +159,5 @@
free($1);
}
+%include "selinuxswig_exception.i"
%include "selinuxswig.i"
+
+
+
+
+
diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinuxswig_wrap.c libselinux-2.0.79/src/selinuxswig_wrap.c
--- nsalibselinux/src/selinuxswig_wrap.c 2009-03-06 14:41:45.000000000 -0500
+++ libselinux-2.0.79/src/selinuxswig_wrap.c 2009-03-27 16:31:56.000000000 -0400

View File

@ -5,7 +5,7 @@
Summary: SELinux library and simple utilities
Name: libselinux
Version: 2.0.79
Release: 4%{?dist}
Release: 5%{?dist}
License: Public Domain
Group: System Environment/Libraries
Source: http://www.nsa.gov/research/selinux/%{name}-%{version}.tgz
@ -164,6 +164,9 @@ exit 0
%{ruby_sitearch}/selinux.so
%changelog
* Thu Apr 2 2009 Dan Walsh <dwalsh@redhat.com> - 2.0.79-5
- Fix crash in python
* Sun Mar 29 2009 Dan Walsh <dwalsh@redhat.com> - 2.0.79-4
- Add back in additional interfaces