Add MLSENabled check

This commit is contained in:
Daniel J Walsh 2006-06-12 18:10:30 +00:00
parent 8389437eda
commit c92317552d
1 changed files with 37 additions and 0 deletions

View File

@ -126,3 +126,40 @@ diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinuxswig_wrap.c libsel
{ (char *)"getseuserbyname", _wrap_getseuserbyname, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
};
--- libselinux-1.30.12/src/setrans_client.c~ 2006-06-05 13:20:37.000000000 -0400
+++ libselinux-1.30.12/src/setrans_client.c 2006-06-12 13:39:55.000000000 -0400
@@ -16,6 +16,9 @@
#include "selinux_internal.h"
#include "setrans_internal.h"
+static int mls_enabled=-1;
+#define MLSENABLED ((mls_enabled==-1) ? (mls_enabled=is_selinux_mls_enabled()) : mls_enabled)
+
// Simple cache
static __thread security_context_t prev_t2r_trans=NULL;
static __thread security_context_t prev_t2r_raw=NULL;
@@ -243,6 +246,12 @@
*rawp = NULL;
return 0;
}
+
+ if (! MLSENABLED) {
+ *rawp = strdup(trans);
+ return 0;
+ }
+
if (cache_trans) {
if (prev_t2r_trans && strcmp(prev_t2r_trans, trans) == 0) {
*rawp=strdup(prev_t2r_raw);
@@ -279,6 +288,11 @@
return 0;
}
+ if (! MLSENABLED) {
+ *transp = strdup(raw);
+ return 0;
+ }
+
if (cache_trans) {
if (prev_r2t_raw && strcmp(prev_r2t_raw, raw) == 0) {
*transp=strdup(prev_r2t_trans);