Skip to contentSkip to conversation

libselinux category patch

PATCH Daniel J Walsh 6 participants 32 messages Aug 23, 2005 – Aug 25, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

libselinux-rhat.patch is mainly tcs's patch with a couple of changes.

One eliminate MLS from the checking. No reason why this has to be MLS specific. Change mlstrans.c to trans.c. See above.
Allow context functions to handle null range.
In MCS I want to translate X:Y:Z:s0 to X:Y:Z, That way we can
introduce MCS policy to targeted without the user
seeing any change.
A couple of minor changes.

setrans.c is the library code

I am attaching the translation library code I am going to throw in for MCS handling. Basically translates
c1=PatientRecord
I have called the file /etc/secat.conf, tried to put it in /etc/selinux/secat.conf, but suddenly lots of domains wanted to read selinux_config_t files.

Is this agreeable to everyone?

Dan

include/selinux/selinux.h +36 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/include/selinux/selinux.h libselinux-1.25.2/include/selinux/selinux.h
@@ -27,6 +27,7 @@
 /* Get current context, and set *con to refer to it.
    Caller must free via freecon. */
 extern int getcon(security_context_t *con);
+extern int getcon_raw(security_context_t *con);
 
 /* Set the current security context to con.  
    Note that use of this function requires that the entire application
@@ -37,32 +38,39 @@
    as a result of a setcon() unless policy allows it to use descriptors opened
    by the old context. */
 extern int setcon(security_context_t con);
+extern int setcon_raw(security_context_t con);
 
 /* Get context of process identified by pid, and 
    set *con to refer to it.  Caller must free via freecon. */
 extern int getpidcon(pid_t pid, security_context_t *con);
+extern int getpidcon_raw(pid_t pid, security_context_t *con);
 
 /* Get previous context (prior to last exec), and set *con to refer to it.
    Caller must free via freecon. */
 extern int getprevcon(security_context_t *con);
+extern int getprevcon_raw(security_context_t *con);
 
 /* Get exec context, and set *con to refer to it.
    Sets *con to NULL if no exec context has been set, i.e. using default.
    If non-NULL, caller must free via freecon. */
 extern int getexeccon(security_context_t *con);
+extern int getexeccon_raw(security_context_t *con);
 
 /* Set exec security context for the next execve. 
    Call with NULL if you want to reset to the default. */
 extern int setexeccon(security_context_t con);
+extern int setexeccon_raw(security_context_t con);
 
 /* Get fscreate context, and set *con to refer to it.
    Sets *con to NULL if no fs create context has been set, i.e. using default.
    If non-NULL, caller must free via freecon. */
 extern int getfscreatecon(security_context_t *con);
+extern int getfscreatecon_raw(security_context_t *con);
 
 /* Set the fscreate security context for subsequent file creations.
    Call with NULL if you want to reset to the default. */
 extern int setfscreatecon(security_context_t context);
+extern int setfscreatecon_raw(security_context_t context);
 
 
 /* Wrappers for the xattr API. */
@@ -70,13 +78,19 @@
 /* Get file context, and set *con to refer to it.
    Caller must free via freecon. */
 extern int getfilecon(const char *path, security_context_t *con);
+extern int getfilecon_raw(const char *path, security_context_t *con);
 extern int lgetfilecon(const char *path, security_context_t *con);
+extern int lgetfilecon_raw(const char *path, security_context_t *con);
 extern int fgetfilecon(int fd, security_context_t *con);
+extern int fgetfilecon_raw(int fd, security_context_t *con);
 
 /* Set file context */
 extern int setfilecon(const char *path, security_context_t con);
+extern int setfilecon_raw(const char *path, security_context_t con);
 extern int lsetfilecon(const char *path, security_context_t con);
+extern int lsetfilecon_raw(const char *path, security_context_t con);
 extern int fsetfilecon(int fd, security_context_t con);
+extern int fsetfilecon_raw(int fd, security_context_t con);
 
 
 /* Wrappers for the socket API */
@@ -84,6 +98,7 @@
 /* Get context of peer socket, and set *con to refer to it.
    Caller must free via freecon. */
 extern int getpeercon(int fd, security_context_t *con);
+extern int getpeercon_raw(int fd, security_context_t *con);
 
 
 /* Wrappers for the selinuxfs (policy) API. */
@@ -105,6 +120,11 @@
 			       security_class_t tclass,
 			       access_vector_t requested,
 			       struct av_decision *avd);
+extern int security_compute_av_raw(security_context_t scon,
+                                   security_context_t tcon,
+                                   security_class_t tclass,
+                                   access_vector_t requested,
+                                   struct av_decision *avd);
 
 /* Compute a labeling decision and set *newcon to refer to it.
    Caller must free via freecon. */
@@ -112,6 +132,10 @@
 				   security_context_t tcon,
 				   security_class_t tclass,
 				   security_context_t *newcon);
+extern int security_compute_create_raw(security_context_t scon,
+                                       security_context_t tcon,
+                                       security_class_t tclass,
+                                       security_context_t *newcon);
 
 /* Compute a relabeling decision and set *newcon to refer to it.
    Caller must free via freecon. */
@@ -119,6 +143,10 @@
 				    security_context_t tcon,
 				    security_class_t tclass,
 				    security_context_t *newcon);
+extern int security_compute_relabel_raw(security_context_t scon,
+                                        security_context_t tcon,
+                                        security_class_t tclass,
+                                        security_context_t *newcon);
 
 /* Compute a polyinstantiation member decision and set *newcon to refer to it.
    Caller must free via freecon. */
@@ -126,12 +154,19 @@
 				   security_context_t tcon,
 				   security_class_t tclass,
 				   security_context_t *newcon);
+extern int security_compute_member_raw(security_context_t scon,
+                                       security_context_t tcon,
+                                       security_class_t tclass,
+                                       security_context_t *newcon);
 
 /* Compute the set of reachable user contexts and set *con to refer to 
    the NULL-terminated array of contexts.  Caller must free via freeconary. */
 extern int security_compute_user(security_context_t scon,
 				 const char *username,
 				 security_context_t **con);
+extern int security_compute_user_raw(security_context_t scon,
+                                     const char *username,
+                                     security_context_t **con);
 
 /* Load a policy configuration. */
 extern int security_load_policy(void *data, size_t len);
@@ -153,6 +188,7 @@
 
 /* Check the validity of a security context. */
 extern int security_check_context(security_context_t con);
+extern int security_check_context_raw(security_context_t con);
 
 /* Get the enforce flag value. */
 extern int security_getenforce(void);
man/man8/selinuxenabled.8 +1 -1
diff --exclude-from=exclude -N -u -r nsalibselinux/man/man8/selinuxenabled.8 libselinux-1.25.2/man/man8/selinuxenabled.8
@@ -7,7 +7,7 @@
 .SH "DESCRIPTION"
 .B selinuxenabled
 Indicates whether SELinux is enabled or disabled. It exits with status 0 
-if SELinux is enabled and -256 if it is not enabled.
+if SELinux is enabled and 1 if it is not enabled.
 
 .SH AUTHOR	
 Dan Walsh, <[email protected]>
src/checkAccess.c +6 -6
diff --exclude-from=exclude -N -u -r nsalibselinux/src/checkAccess.c libselinux-1.25.2/src/checkAccess.c
@@ -11,13 +11,13 @@
         security_context_t user_context;
         if (is_selinux_enabled() == 0) 
                 return 0;
-        if( getprevcon(&user_context)==0 ) {
+        if( getprevcon_raw(&user_context)==0 ) {
                 struct av_decision avd;
-                int retval = security_compute_av(user_context,
-                                                 user_context,
-                                                 SECCLASS_PASSWD,
-                                                 requested,
-                                                 &avd);
+                int retval = security_compute_av_raw(user_context,
+                                                     user_context,
+                                                     SECCLASS_PASSWD,
+                                                     requested,
+                                                     &avd);
                 
                 if ((retval == 0) && 
                     ((requested & avd.allowed) == requested)) {
src/check_context.c +18 -1
diff --exclude-from=exclude -N -u -r nsalibselinux/src/check_context.c libselinux-1.25.2/src/check_context.c
@@ -9,7 +9,7 @@
 #include "policy.h"
 #include <limits.h>
 
-int security_check_context(security_context_t con)
+int security_check_context_raw(security_context_t con)
 {
 	char path[PATH_MAX];
 	int fd, ret;
@@ -25,4 +25,21 @@
 		return -1;
 	return 0;
 }
+hidden_def(security_check_context_raw)
+
+int security_check_context(security_context_t con)
+{
+	int ret;
+	security_context_t rcon = con;
+
+	if (context_translations && trans_to_raw_context(con, &rcon))
+		return -1;
+
+ 	ret = security_check_context_raw(rcon);
+
+	if (context_translations)
+		freecon(rcon);
+
+	return ret;
+}
 hidden_def(security_check_context)
src/compute_av.c +35 -5
diff --exclude-from=exclude -N -u -r nsalibselinux/src/compute_av.c libselinux-1.25.2/src/compute_av.c
@@ -10,11 +10,11 @@
 #include "policy.h"
 #include <limits.h>
 
-int security_compute_av(security_context_t scon,
-			security_context_t tcon,
-			security_class_t tclass,
-			access_vector_t requested,
-			struct av_decision *avd)
+int security_compute_av_raw(security_context_t scon,
+                            security_context_t tcon,
+                            security_class_t tclass,
+                            access_vector_t requested,
+                            struct av_decision *avd)
 {
 	char path[PATH_MAX];
 	char *buf;
@@ -58,4 +58,34 @@
 	close(fd);
 	return ret;
 }
+hidden_def(security_compute_av_raw)
+
+int security_compute_av(security_context_t scon,
+                        security_context_t tcon,
+                        security_class_t tclass,
+                        access_vector_t requested,
+                        struct av_decision *avd)
+{
+	int ret;
+	security_context_t rscon = scon;
+	security_context_t rtcon = tcon;
+
+	if (context_translations) {
+		if (trans_to_raw_context(scon, &rscon))
+			return -1;
+		if (trans_to_raw_context(tcon, &rtcon)) {
+			freecon(rscon);
+			return -1;
+		}
+	}
+
+ 	ret = security_compute_av_raw(rscon, rtcon, tclass, requested, avd);
+
+	if (context_translations) {
+		freecon(rscon);
+		freecon(rtcon);
+	}
+
+	return ret;
+}
 hidden_def(security_compute_av)
src/compute_create.c +42 -4

56 lines not on this page · raw message

src/compute_member.c +42 -5

59 lines not on this page · raw message

src/compute_relabel.c +42 -5

59 lines not on this page · raw message

src/compute_user.c +35 -3
diff --exclude-from=exclude -N -u -r nsalibselinux/src/compute_user.c libselinux-1.25.2/src/compute_user.c
@@ -10,9 +10,9 @@
 #include "policy.h"
 #include <limits.h>
 
-int security_compute_user(security_context_t scon,
-			  const char *user,
-			  security_context_t **con)
+int security_compute_user_raw(security_context_t scon,
+                              const char *user,
+                              security_context_t **con)
 {
 	char path[PATH_MAX];
 	char **ary;
@@ -73,4 +73,36 @@
 	close(fd);
 	return ret;
 }
+hidden_def(security_compute_user_raw)
+
+int security_compute_user(security_context_t scon,
+                          const char *user,
+                          security_context_t **con)
+{
+	int ret;
+	security_context_t rscon = scon;
+
+	if (context_translations && trans_to_raw_context(scon, &rscon))
+		return -1;
+
+ 	ret = security_compute_user_raw(rscon, user, con);
+
+	if (context_translations) {
+		freecon(rscon);
+		if (!ret) {
+			security_context_t *ptr, tmpcon;
+			for (ptr = *con; *ptr; ptr++) {
+				if (raw_to_trans_context(*ptr, &tmpcon)) {
+					freeconary(*con);
+					*con = NULL;
+					return -1;
+				}
+				freecon(*ptr);
+				*ptr = tmpcon;
+			}
+		}
+	}
+
+	return ret;
+}
 hidden_def(security_compute_user)
src/context.c +6 -4
diff --exclude-from=exclude -N -u -r nsalibselinux/src/context.c libselinux-1.25.2/src/context.c
@@ -15,7 +15,8 @@
 
 /*
  * Allocate a new context, initialized from str.  There must be 3 or
- * 4 colon-separated components and no whitespace.
+ * 4 colon-separated components and no whitespace in the user, role, or type
+ * components.  MLS components may have spaces in translated form.
  */
 context_t
 context_new(const char *str)
@@ -35,7 +36,8 @@
         for ( i = count = 0, p = str; *p; p++ ) {
                 switch ( *p ) { 
                 case ':': count++; break;
-                case '\n': case '\t': case '\r': case ' ': goto err; /* sanity check */
+                case '\n': case '\t': case '\r': goto err; /* sanity check */
+                case ' ': if (count < 3) goto err; /* sanity check */
                 }
         }
 	/*
@@ -141,8 +143,8 @@
         const char *p;
         if ( !t ) { return 1; }
         for ( p = str; *p; p++ ) {
-                if ( *p == '\t' || *p == ' ' || *p == '\n' || *p == '\r' ||
-                     (*p == ':' && index != COMP_RANGE) ) {
+                if ( *p == '\t' || *p == '\n' || *p == '\r' ||
+                     ((*p == ':' || *p == ' ') && index != COMP_RANGE) ) {
                         free(t);
                         return 1;
                 }
src/enabled.c +1 -1
diff --exclude-from=exclude -N -u -r nsalibselinux/src/enabled.c libselinux-1.25.2/src/enabled.c
@@ -42,7 +42,7 @@
 
 	enabled = 1;
 
-	if (getcon(&con) == 0) {
+	if (getcon_raw(&con) == 0) {
 		if (!strcmp(con, "kernel"))
 			enabled = 0;
 		freecon(con);
src/fgetfilecon.c +21 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/fgetfilecon.c libselinux-1.25.2/src/fgetfilecon.c
@@ -1,13 +1,13 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
-#include <selinux/selinux.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/xattr.h>
+#include "selinux_internal.h"
 #include "policy.h"
 
-int fgetfilecon(int fd, security_context_t *context)
+int fgetfilecon_raw(int fd, security_context_t *context)
 {
 	char *buf;
 	ssize_t size;
@@ -43,3 +43,22 @@
 		*context = buf;
 	return ret;
 }
+
+int fgetfilecon(int fd, security_context_t *context)
+{
+	security_context_t rcontext;
+	int ret;
+
+ 	ret = fgetfilecon_raw(fd, &rcontext);
+
+	if (context_translations && ret > 0) {
+		if (raw_to_trans_context(rcontext, context)) {
+			*context = NULL;
+			ret = -1;
+		}
+		freecon(rcontext);
+	} else
+		*context = rcontext;
+
+	return ret;
+}
src/fsetfilecon.c +18 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/fsetfilecon.c libselinux-1.25.2/src/fsetfilecon.c
@@ -1,13 +1,29 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
-#include <selinux/selinux.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/xattr.h>
+#include "selinux_internal.h"
 #include "policy.h"
 
-int fsetfilecon(int fd, security_context_t context)
+int fsetfilecon_raw(int fd, security_context_t context)
 {
 	return fsetxattr(fd, XATTR_NAME_SELINUX, context, strlen(context)+1, 0);
 }
+
+int fsetfilecon(int fd, security_context_t context)
+{
+	int ret;
+	security_context_t rcontext = context;
+
+	if (context_translations && trans_to_raw_context(context, &rcontext))
+		return -1;
+
+ 	ret = fsetfilecon_raw(fd, rcontext);
+
+	if (context_translations)
+		freecon(rcontext);
+
+	return ret;
+}
src/getcon.c +21 -1
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getcon.c libselinux-1.25.2/src/getcon.c
@@ -7,7 +7,7 @@
 #include <asm/page.h>
 #include "policy.h"
 
-int getcon(security_context_t *context)
+int getcon_raw(security_context_t *context)
 {
 	char *buf;
 	size_t size;
@@ -42,4 +42,24 @@
 	close(fd);
 	return ret;
 }
+hidden_def(getcon_raw)
+
+int getcon(security_context_t *context)
+{
+	int ret;
+	security_context_t rcontext;
+
+ 	ret = getcon_raw(&rcontext);
+
+	if (context_translations && !ret) {
+		if (raw_to_trans_context(rcontext, context)) {
+			*context = NULL;
+			ret = -1;
+		}
+		freecon(rcontext);
+	} else
+		*context = rcontext;
+
+	return ret;
+}
 hidden_def(getcon)
src/getexeccon.c +21 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getexeccon.c libselinux-1.25.2/src/getexeccon.c
@@ -1,13 +1,13 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
-#include <selinux/selinux.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <asm/page.h>
+#include "selinux_internal.h"
 #include "policy.h"
 
-int getexeccon(security_context_t *context)
+int getexeccon_raw(security_context_t *context)
 {
 	char *buf;
 	size_t size;
@@ -47,3 +47,22 @@
 	close(fd);
 	return ret;
 }
+
+int getexeccon(security_context_t *context)
+{
+	int ret;
+	security_context_t rcontext;
+
+ 	ret = getexeccon_raw(&rcontext);
+
+	if (context_translations && !ret) {
+		if (raw_to_trans_context(rcontext, context)) {
+			*context = NULL;
+			ret = -1;
+		}
+		freecon(rcontext);
+	} else
+		*context = rcontext;
+
+	return ret;
+}
src/getfilecon.c +21 -1
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getfilecon.c libselinux-1.25.2/src/getfilecon.c
@@ -7,7 +7,7 @@
 #include <sys/xattr.h>
 #include "policy.h"
 
-int getfilecon(const char *path, security_context_t *context)
+int getfilecon_raw(const char *path, security_context_t *context)
 {
 	char *buf;
 	ssize_t size;
@@ -43,4 +43,24 @@
 		*context = buf;
 	return ret;
 }
+hidden_def(getfilecon_raw)
+
+int getfilecon(const char *path, security_context_t *context)
+{
+	int ret;
+	security_context_t rcontext;
+
+ 	ret = getfilecon_raw(path, &rcontext);
+
+	if (context_translations && ret > 0) {
+		if (raw_to_trans_context(rcontext, context)) {
+			*context = NULL;
+			ret = -1;
+		}
+		freecon(rcontext);
+	} else
+		*context = rcontext;
+
+	return ret;
+}
 hidden_def(getfilecon)
src/getfscreatecon.c +21 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getfscreatecon.c libselinux-1.25.2/src/getfscreatecon.c
@@ -1,13 +1,13 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
-#include <selinux/selinux.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <asm/page.h>
+#include "selinux_internal.h"
 #include "policy.h"
 
-int getfscreatecon(security_context_t *context)
+int getfscreatecon_raw(security_context_t *context)
 {
 	char *buf;
 	size_t size;
@@ -47,3 +47,22 @@
 	close(fd);
 	return ret;
 }
+
+int getfscreatecon(security_context_t *context)
+{
+	int ret;
+	security_context_t rcontext;
+
+ 	ret = getfscreatecon_raw(&rcontext);
+
+	if (context_translations && !ret) {
+		if (raw_to_trans_context(rcontext, context)) {
+			*context = NULL;
+			ret = -1;
+		}
+		freecon(rcontext);
+	} else
+		*context = rcontext;
+
+	return ret;
+}
src/getpeercon.c +21 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getpeercon.c libselinux-1.25.2/src/getpeercon.c
@@ -1,17 +1,17 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
-#include <selinux/selinux.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/socket.h>
+#include "selinux_internal.h"
 #include "policy.h"
 
 #ifndef SO_PEERSEC
 #define SO_PEERSEC 31
 #endif
 
-int getpeercon(int fd, security_context_t *context)
+int getpeercon_raw(int fd, security_context_t *context)
 {
 	char *buf;
 	socklen_t size;
@@ -42,3 +42,22 @@
 		*context = buf;
 	return ret;
 }
+
+int getpeercon(int fd, security_context_t *context)
+{
+	int ret;
+	security_context_t rcontext;
+
+ 	ret = getpeercon_raw(fd, &rcontext);
+
+	if (context_translations && !ret) {
+		if (raw_to_trans_context(rcontext, context)) {
+			*context = NULL;
+			ret = -1;
+		}
+		freecon(rcontext);
+	} else
+		*context = rcontext;
+
+	return ret;
+}
src/getpidcon.c +21 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getpidcon.c libselinux-1.25.2/src/getpidcon.c
@@ -1,14 +1,14 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
-#include <selinux/selinux.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <asm/page.h>
+#include "selinux_internal.h"
 #include "policy.h"
 
-int getpidcon(pid_t pid, security_context_t *context)
+int getpidcon_raw(pid_t pid, security_context_t *context)
 {
 	char path[40];
 	char *buf;
@@ -46,3 +46,22 @@
 	close(fd);
 	return ret;
 }
+
+int getpidcon(pid_t pid, security_context_t *context)
+{
+	int ret;
+	security_context_t rcontext;
+
+ 	ret = getpidcon_raw(pid, &rcontext);
+
+	if (context_translations && !ret) {
+		if (raw_to_trans_context(rcontext, context)) {
+			*context = NULL;
+			ret = -1;
+		}
+		freecon(rcontext);
+	} else
+		*context = rcontext;
+
+	return ret;
+}
src/getprevcon.c +21 -1
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getprevcon.c libselinux-1.25.2/src/getprevcon.c
@@ -7,7 +7,7 @@
 #include <asm/page.h>
 #include "policy.h"
 
-int getprevcon(security_context_t *context)
+int getprevcon_raw(security_context_t *context)
 {
 	char *buf;
 	size_t size;
@@ -42,4 +42,24 @@
 	close(fd);
 	return ret;
 }
+hidden_def(getprevcon_raw)
+
+int getprevcon(security_context_t *context)
+{
+	int ret;
+	security_context_t rcontext;
+
+ 	ret = getprevcon_raw(&rcontext);
+
+	if (context_translations && !ret) {
+		if (raw_to_trans_context(rcontext, context)) {
+			*context = NULL;
+			ret = -1;
+		}
+		freecon(rcontext);
+	} else
+		*context = rcontext;
+
+	return ret;
+}
 hidden_def(getprevcon)
src/init.c +58 -4

82 lines not on this page · raw message

src/lgetfilecon.c +21 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/lgetfilecon.c libselinux-1.25.2/src/lgetfilecon.c
@@ -1,13 +1,13 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
-#include <selinux/selinux.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/xattr.h>
+#include "selinux_internal.h"
 #include "policy.h"
 
-int lgetfilecon(const char *path, security_context_t *context)
+int lgetfilecon_raw(const char *path, security_context_t *context)
 {
 	char *buf;
 	ssize_t size;
@@ -43,3 +43,22 @@
 		*context = buf;
 	return ret;
 }
+
+int lgetfilecon(const char *path, security_context_t *context)
+{
+	int ret;
+	security_context_t rcontext;
+
+ 	ret = lgetfilecon_raw(path, &rcontext);
+
+	if (context_translations && ret > 0) {
+		if (raw_to_trans_context(rcontext, context)) {
+			*context = NULL;
+			ret = -1;
+		}
+		freecon(rcontext);
+	} else
+		*context = rcontext;
+
+	return ret;
+}
src/lsetfilecon.c +18 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/lsetfilecon.c libselinux-1.25.2/src/lsetfilecon.c
@@ -1,13 +1,29 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
-#include <selinux/selinux.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/xattr.h>
+#include "selinux_internal.h"
 #include "policy.h"
 
-int lsetfilecon(const char *path, security_context_t context)
+int lsetfilecon_raw(const char *path, security_context_t context)
 {
 	return lsetxattr(path, XATTR_NAME_SELINUX, context, strlen(context)+1, 0);
 }
+
+int lsetfilecon(const char *path, security_context_t context)
+{
+	int ret;
+	security_context_t rcontext = context;
+
+	if (context_translations && trans_to_raw_context(context, &rcontext))
+		return -1;
+
+ 	ret = lsetfilecon_raw(path, rcontext);
+
+	if (context_translations)
+		freecon(rcontext);
+
+	return ret;
+}
src/matchmediacon.c +9 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/matchmediacon.c libselinux-1.25.2/src/matchmediacon.c
@@ -58,7 +58,14 @@
 	if (!(*ptr2)) {
 		return -1;
 	}
-	
-	*con = strdup(ptr2);
+
+	if (context_translations) {
+		if (raw_to_trans_context(ptr2, con)) {
+			*con = NULL;
+			return -1;
+		}
+	} else
+		*con = strdup(ptr2);
+
 	return 0;
 }
src/matchpathcon.c +12 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/matchpathcon.c libselinux-1.25.2/src/matchpathcon.c
@@ -514,6 +514,18 @@
 		spec_arr[nspec].context = context;
 		
 		if (strcmp(context, "<<none>>")) {
+			if (context_translations) {
+				if (raw_to_trans_context(context,
+				                    &spec_arr[nspec].context)) {
+					myprintf("%s: line %u has invalid "
+					         "context %s\n",
+					         path, lineno, context);
+					return 0;
+				}
+				free(context);
+				context = spec_arr[nspec].context;
+			}
+
 			if (myinvalidcon(path, lineno, context))
 				return 0;
 		}
src/rpm.c +4 -4
diff --exclude-from=exclude -N -u -r nsalibselinux/src/rpm.c libselinux-1.25.2/src/rpm.c
@@ -16,15 +16,15 @@
 	if (is_selinux_enabled() < 1)
 		return execve(filename, argv, envp);
 
-	rc = getcon(&mycon);
+	rc = getcon_raw(&mycon);
 	if (rc < 0)
 		goto out;
 
-	rc = getfilecon(filename, &fcon);
+	rc = getfilecon_raw(filename, &fcon);
 	if (rc < 0)
 		goto out;
 
-	rc = security_compute_create(mycon, fcon, SECCLASS_PROCESS, &newcon);
+	rc = security_compute_create_raw(mycon, fcon, SECCLASS_PROCESS, &newcon);
 	if (rc < 0)
 		goto out;
 
@@ -41,7 +41,7 @@
 			goto out;
 	}
 
-	rc = setexeccon(newcon);
+	rc = setexeccon_raw(newcon);
 	if (rc < 0) 
 		goto out;
 	rc = execve(filename, argv, envp);
src/selinux_internal.h +12 -1
diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinux_internal.h libselinux-1.25.2/src/selinux_internal.h
@@ -4,18 +4,25 @@
 hidden_proto(security_set_boolean)
 hidden_proto(security_commit_booleans)
 hidden_proto(security_check_context)
+hidden_proto(security_check_context_raw)
 hidden_proto(security_compute_av)
+hidden_proto(security_compute_av_raw)
 hidden_proto(security_compute_user)
+hidden_proto(security_compute_user_raw)
 hidden_proto(security_compute_create)
+hidden_proto(security_compute_create_raw)
 hidden_proto(is_selinux_enabled)
 hidden_proto(is_selinux_mls_enabled)
-hidden_proto(security_check_context)
 hidden_proto(freecon)
 hidden_proto(freeconary)
 hidden_proto(getprevcon)
+hidden_proto(getprevcon_raw)
 hidden_proto(getcon)
+hidden_proto(getcon_raw)
 hidden_proto(getfilecon)
+hidden_proto(getfilecon_raw)
 hidden_proto(setexeccon)
+hidden_proto(setexeccon_raw)
 hidden_proto(security_getenforce)
 hidden_proto(selinux_default_context_path)
 hidden_proto(selinux_failsafe_context_path)
@@ -27,3 +34,7 @@
 hidden_proto(selinux_media_context_path)
 hidden_proto(matchpathcon_init)
 hidden_proto(selinux_users_path)
+
+extern int context_translations;
+extern int trans_to_raw_context(char *raw, char **transp);
+extern int raw_to_trans_context(char *trans, char **rawp);
src/setcon.c +18 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/setcon.c libselinux-1.25.2/src/setcon.c
@@ -5,9 +5,9 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
-#include <selinux/selinux.h>
+#include "selinux_internal.h"
 
-int setcon(security_context_t context)
+int setcon_raw(security_context_t context)
 {
 	int fd;
 	ssize_t ret;
@@ -25,3 +25,19 @@
 	else
 		return 0;
 }
+
+int setcon(char *context)
+{
+	int ret;
+	security_context_t rcontext = context;
+
+	if (context_translations && trans_to_raw_context(context, &rcontext))
+		return -1;
+
+ 	ret = setcon_raw(rcontext);
+
+	if (context_translations)
+		freecon(rcontext);
+
+	return ret;
+}
src/setexeccon.c +18 -1
diff --exclude-from=exclude -N -u -r nsalibselinux/src/setexeccon.c libselinux-1.25.2/src/setexeccon.c
@@ -3,7 +3,7 @@
 #include <string.h>
 #include "selinux_internal.h"
 
-int setexeccon(security_context_t context)
+int setexeccon_raw(security_context_t context)
 {
 	int fd;
 	ssize_t ret;
@@ -21,4 +21,21 @@
 	else
 		return 0;
 }
+hidden_def(setexeccon_raw)
+
+int setexeccon(char *context)
+{
+	int ret;
+	security_context_t rcontext = context;
+
+	if (context_translations && trans_to_raw_context(context, &rcontext))
+		return -1;
+
+ 	ret = setexeccon_raw(rcontext);
+
+	if (context_translations)
+		freecon(rcontext);
+
+	return ret;
+}
 hidden_def(setexeccon)
src/setfilecon.c +18 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/setfilecon.c libselinux-1.25.2/src/setfilecon.c
@@ -1,13 +1,29 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
-#include <selinux/selinux.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/xattr.h>
+#include "selinux_internal.h"
 #include "policy.h"
 
-int setfilecon(const char *path, security_context_t context)
+int setfilecon_raw(const char *path, security_context_t context)
 {
 	return setxattr(path, XATTR_NAME_SELINUX, context, strlen(context)+1, 0);
 }
+
+int setfilecon(const char *path, security_context_t context)
+{
+	int ret;
+	security_context_t rcontext = context;
+
+	if (context_translations && trans_to_raw_context(context, &rcontext))
+		return -1;
+
+ 	ret = setfilecon_raw(path, rcontext);
+
+	if (context_translations)
+		freecon(rcontext);
+
+	return ret;
+}
src/setfscreatecon.c +18 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/setfscreatecon.c libselinux-1.25.2/src/setfscreatecon.c
@@ -1,9 +1,9 @@
 #include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
-#include <selinux/selinux.h>
+#include "selinux_internal.h"
 
-int setfscreatecon(char *context)
+int setfscreatecon_raw(char *context)
 {
 	int fd;
 	ssize_t ret;
@@ -21,3 +21,19 @@
 	else
 		return 0;
 }
+
+int setfscreatecon(char *context)
+{
+	int ret;
+	security_context_t rcontext = context;
+
+	if (context_translations && trans_to_raw_context(context, &rcontext))
+		return -1;
+
+ 	ret = setfscreatecon_raw(rcontext);
+
+	if (context_translations)
+		freecon(rcontext);
+
+	return ret;
+}
src/trans.c +32 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/trans.c libselinux-1.25.2/src/trans.c
@@ -0,0 +1,32 @@
+#include "selinux_internal.h"
+#include <string.h>
+
+int (*lib_trans_to_raw_context)(char *raw, char **transp) = NULL;
+int (*lib_raw_to_trans_context)(char *trans, char **rawp) = NULL;
+
+int trans_to_raw_context(char *raw, char **transp)
+{
+	if (!raw) {
+		*transp = NULL;
+		return 0;
+	}
+
+	if (lib_trans_to_raw_context(raw, transp))
+		*transp = strdup(raw);
+
+	return transp ? 0 : -1;
+}
+
+int raw_to_trans_context(char *trans, char **rawp)
+{
+	if (!trans) {
+		*rawp = NULL;
+		return 0;
+	}
+
+	if (lib_raw_to_trans_context(trans, rawp))
+		*rawp = strdup(trans);
+
+	return rawp ? 0 : -1;
+}
+

#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <selinux/selinux.h>
#include <selinux/context.h>

#define CATEGORYFILE "/etc/secat.conf"

/* Define data structures */

typedef struct selevel {
	char* name;
	char* sename;
} selevel_t;

/* catlist is a simple linked list of selevels extracted from the CATEGORYFILE */

typedef struct cat {
	struct cat *next;
	selevel_t level;
} cat_t;

static cat_t *catlist=NULL;

/* Remove excess white space */

static char *strtrim(char *dest, char *source, int size) {
	int i=0;
	char *ptr=source;
	i=0;
	while(isspace(*ptr) && i < size) {
		ptr++;
		i++;
	}
	strncpy(dest,ptr,size);
	for(i=strlen(dest)-1; i> 0; i--) {
		if (!isspace(dest[i])) break;
	}
	dest[i+1]='\0';
	return dest;
}
/* Process line from CATEGORYFILE. 
   Remove white space and set name do data before the "=" and sename to data
   after it */
static int process_category(char *buffer, cat_t **cat) {
	char name[BUFSIZ];
	char name1[BUFSIZ];
	int namesize=sizeof(name);
	struct cat *next;
	char *ptr;
	char *tok=strtok_r(buffer,"=",&ptr);
	if (!tok) return 0;
	strncpy(name1,tok, BUFSIZ-1);
	strtrim(name,name1,namesize-1);
	if ( name[0]=='#' ) return 0;
	tok=strtok_r(NULL,"\0",&ptr);
	if (!tok) return 0;
	while (isspace(*tok)) tok++;
	next=(cat_t *) calloc(sizeof(cat_t), 1);
	if (!next) return 0;
	next->level.name=strdup(name);
	if (!next->level.name) {
		free(next);
		return 0;
	}
	strncpy(name1,tok, BUFSIZ-1);
	strtrim(name,name1,namesize-1);
	next->level.sename=strdup(name);
	if (!next->level.sename) {
		free(next->level.name);
		free(next);
		return 0;
	}
	*cat=next;
	return 1;
}

/* Read in CATEGORYFILE Only runs once per process.
Might want to change to some kind of reload eventually, for long running processes.
*/

int init_context_translations() {
	FILE *cfg;
	cat_t *ptr=NULL;
	cat_t *next=NULL;
	size_t size=0;
	char *buffer=NULL;
	int ctr=0;
	if (catlist) return 0;
	cfg = fopen(CATEGORYFILE,"r");
	if (cfg == NULL) 
		return 1;

	ptr=catlist=calloc(1,sizeof(cat_t));
	while (getline(&buffer, &size, cfg) > 0) {
		if (process_category(buffer, &next)) {
			ctr++;
			ptr->next=next;
			ptr=next;
		}
	}
	if (buffer)
		free(buffer);
	return 0;
}

/* Look for selevel via internal name */

static char *translate(const char *cat) {
	cat_t *ptr=NULL;
	if (catlist) 
		for (ptr=catlist->next;ptr; ptr=ptr->next) 
			if (strcmp(cat,ptr->level.name)==0) 
				return strdup(ptr->level.sename); 
	return strdup(cat);
}

/* Look for selevel via external name */

static char *untranslate(const char *sename) {
	cat_t *ptr=NULL;
	if (catlist) 
		for(ptr=catlist->next;ptr; ptr=ptr->next)
			if (strcmp(sename,ptr->level.sename)==0) 
				return strdup(ptr->level.name); 
	return strdup(sename);
}

/* Look for selevel via external name */

int translate_context( const security_context_t oldcon, security_context_t *rcon) {
	const char *range=NULL;
	char *newrange=NULL;
	const char *ptr=NULL;
	context_t con=context_new(oldcon);

	if (! con)
		return -1;

	range=context_range_get(con);
	if (range) {
		if(strcmp(range,"s0") == 0 ) {
			context_range_set(con,NULL);
		}
		else 
		{
			ptr=strrchr(range,':');
			if (ptr) 
				ptr++;
			else
				ptr=range;
			newrange=translate(ptr);
			if (newrange) {
				context_range_set(con,newrange);
			}
		}
	}
	*rcon=strdup(context_str(con));
	context_free(con);
	return 0;
}

/* Look for selevel via external name */

int untranslate_context( const security_context_t oldcon, security_context_t *rcon) {
	const char *range=NULL;
	char *newrange=NULL;
	context_t con=context_new(oldcon);

	if (! con)
		return -1;

	range=context_range_get(con);
	if (range) {
		newrange=untranslate(range);
		if (newrange) {
			context_range_set(con,newrange);
		}
	}
	*rcon=strdup(context_str(con));
	context_free(con);
	return 0;
}
#1 lore raw
Quoted 11 lines · Daniel J Walsh

libselinux-rhat.patch is mainly tcs's patch with a couple of changes.

One eliminate MLS from the checking. No reason why this has to be MLS specific.
Change mlstrans.c to trans.c. See above.
Allow context functions to handle null range.
In MCS I want to translate X:Y:Z:s0 to X:Y:Z, That way we can
introduce MCS policy to targeted without the user
seeing any change.
A couple of minor changes.

Quoted 8 lines

setrans.c is the library code

I am attaching the translation library code I am going to throw in for MCS handling. Basically translates
c1=PatientRecord
I have called the file /etc/secat.conf, tried to put it in /etc/selinux/secat.conf, but suddenly lots of domains wanted to read selinux_config_t files.

- Putting it directly under /etc makes it harder to protect differently than any other top-level /etc file. On the other hand, it is very much like a passwd file lookup for mapping uids to usernames for e.g. ls, ps, and friends.
- Placing it outside of /etc/selinux makes sense if it is not considered part of the SELinux policy, and is consistent with the ultimate goal of being able to manage it via LDAP or similar means. But it does raise the question of what owns this file, and how it gets set up initially, e.g. one might want different default for MCS vs. MLS.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 5 lines · Stephen Smalley
Quoted 3 lines · Daniel J Walsh

I am attaching the translation library code I am going to throw in for MCS handling. Basically translates
c1=PatientRecord
I have called the file /etc/secat.conf, tried to put it in /etc/selinux/secat.conf, but suddenly lots of domains wanted to read selinux_config_t files.

Quoted 10 lines

- Putting it directly under /etc makes it harder to protect differently than any other top-level /etc file. On the other hand, it is very much like a passwd file lookup for mapping uids to usernames for e.g. ls, ps, and friends.
- Placing it outside of /etc/selinux makes sense if it is not considered part of the SELinux policy, and is consistent with the ultimate goal of being able to manage it via LDAP or similar means. But it does raise the question of what owns this file, and how it gets set up initially, e.g. one might want different default for MCS vs. MLS.

We (TCS) are including the label translation files under /etc/selinux (protected at system high as selinux_config_t) because we view this as part of the SELinux configuration. This works for us because we have a daemon which is the single user of this file other than the security admin. Our libsetrans is simply a communication library to the daemon. If the file is read directly by users of libselinux, it needs to be protected in such a way that everyone who can make a call into libselinux can read the file. Note that we have a similar issue regarding users of libselinux - they must be able to contact the daemon. We have created a policy macro for things that use our daemon via libselinux. Perhaps we should introduce an attribute that identifies users of libselinux. This attribute can then be used to grant read access to the config file in RedHat's case and access to the daemon in our case.
Any thoughts on that? Maybe 'privsetrans'?

Signature · 6 lines
Darrel

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw
Quoted 3 lines · Darrel Goeddel

We (TCS) are including the label translation files under /etc/selinux (protected at system high as selinux_config_t) because we view this as part of the SELinux configuration.

Ok, but what happens when this mapping (plus the Linux user->{SELinux user, allowed category set} mapping) gets pushed into an LDAP directory? One of the points of separating it from the policy is so that you can ship a single relatively static policy and local admins can manage their site-specific settings without touching the policy proper, iirc.

Quoted 11 lines

This works for us because we have a daemon which is
the single user of this file other than the security admin. Our libsetrans is simply a communication library to the daemon. If the file is read directly by users of libselinux, it needs to be protected in such a way that everyone who can make a call into libselinux can read the file. Note that we have a similar issue regarding users of libselinux - they must be able to contact the daemon. We have created a policy macro for things that use our daemon via libselinux. Perhaps we should introduce an attribute that identifies users of libselinux. This attribute can then be used to grant read access to the config file in RedHat's case and access to the daemon in our case.
Any thoughts on that? Maybe 'privsetrans'?

Explicit macro interfaces are preferable, e.g. uses_libselinux(name_of_domain). But a point to note here is that different users of libselinux have different permission requirements, e.g. some only need to use interfaces like getfilecon/getcon and do not need access to the policy files (other than the translation mapping) or selinuxfs. There are already macros for things like can_getcon and can_getsecurity, so possibly we want specific macros along those lines rather than a generic uses_libselinux.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw
In reply to Daniel J Walsh
Quoted 10 lines · Daniel J Walsh
	range=context_range_get(con);
	if (range) {
		if(strcmp(range,"s0") == 0 ) {
			context_range_set(con,NULL);
		}
		else 
		{
			ptr=strrchr(range,':');

Why is s0 hardcoded here? s0 should be part of the context to be translated, if you don't want the users to see it whatever tool to edit the mappings should hide it, not libselinux.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#5 lore raw
Quoted 11 lines · Joshua Brindle
Quoted 9 lines · Daniel J Walsh
    range=context_range_get(con);
    if (range) {
        if(strcmp(range,"s0") == 0 ) {
            context_range_set(con,NULL);
        }
        else         {
            ptr=strrchr(range,':');
Quoted 1 line

Why is s0 hardcoded here? s0 should be part of the context to be translated, if you don't want the users to see it whatever tool to edit the mappings should hide it, not libselinux.

This code is not part of libselinux, it is a library that SELinux calls out to that will be specific to the vendor that ships it. I see this library being different between our version of MCS/MLS and other third party versions of MLS, IE one that translates using the Mitre Libraries.

MCS version of libtrans.so translates s0->"".

MLS policy can do what ever it wants with this part of the range.

Signature · 4 lines
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#6 lore raw
Quoted 9 lines · Daniel J Walsh

This code is not part of libselinux, it is a library that SELinux calls out to that will be specific to the vendor that ships it.
I see this library being different between our version of MCS/MLS and other third party versions of MLS, IE one that translates using the Mitre Libraries.

MCS version of libtrans.so translates s0->"".

MLS policy can do what ever it wants with this part of the range.

While it is true that systems with a real MLS policy will likely have their own libsetrans implementation, I think it would make sense to have your default libsetrans implementation at least provide a way to map sensitivity names as well as category names via the config file, including a way to specify that they should just be dropped (e.g. s0=""). Whether or not you should further allow mapping of entire combinations, like s0:c0,c127=puritycontrol, via the config in your default libsetrans implementation is more open to debate.

Also, how do you intend to deal with multiple libsetrans implementations? Symlink to the real translation library? Managed via the alternatives system?

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#7 lore raw
Quoted 12 lines · Stephen Smalley
Quoted 8 lines · Daniel J Walsh

This code is not part of libselinux, it is a library that SELinux calls out to that will be specific to the vendor that ships it. I see this library being different between our version of MCS/MLS and other third party versions of MLS, IE one that translates using the Mitre Libraries.

MCS version of libtrans.so translates s0->"".

MLS policy can do what ever it wants with this part of the range.

Quoted 10 lines

While it is true that systems with a real MLS policy will likely have their own libsetrans implementation, I think it would make sense to have your default libsetrans implementation at least provide a way to map sensitivity names as well as category names via the config file, including a way to specify that they should just be dropped (e.g. s0=""). Whether or not you should further allow mapping of entire combinations, like s0:c0,c127=puritycontrol, via the config in your default libsetrans implementation is more open to debate.

I was thinking of issue of the multiple translations and how to do SystemHigh also. Currently I am just truncating off
the s0: and asking for a translation of the remainder. So c0,c127 would translate to puritycontrol. Translating s0="" Would give me better flexibility though, so I guess I can adopt it. I was considering allowing users to specify multiple Categories on a file and then translating it, but it probably would be better to force the user to specify a name for multiple categories.

c1,c5,c7=CompanyConfidential_CokeSecretRecipe_PrintOnly

Quoted 6 lines

Also, how do you intend to deal with multiple libsetrans implementations? Symlink to the real translation library? Managed via the alternatives system?

I was thinking conflicting rpm packages. So You can not install MCS and MLS translation libaries at the same time.

Signature · 4 lines
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#8 lore raw
Quoted 3 lines · Daniel J Walsh

I was thinking of issue of the multiple translations and how to do SystemHigh also. Currently I am just truncating off the s0: and asking for a translation of the remainder.

Seems like you want to able to support mapping particular combinations (c0.c127=purity_control) as well as individual components (c42=cassandra_spender), possibly falling through to individual component translation if there is no mapping for the complete combination. Otherwise, you have to specify all possible combinations, right?

Quoted 2 lines

I was thinking conflicting rpm packages. So You can not install MCS and MLS translation libaries at the same time.

Hmmm...I recall that you didn't want to take that approach for multiple policies, but in that case, you were providing multiple policies in the distribution itself. As long as you don't think you will ever need to support multiple translation libraries in the base distribution, then conflicting packages may be ok. Darrel, what do you think?

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#9 lore raw
Quoted 8 lines · Stephen Smalley
Quoted 1 line

I was thinking conflicting rpm packages. So You can not install MCS and MLS translation libaries at the same time.

Hmmm...I recall that you didn't want to take that approach for multiple policies, but in that case, you were providing multiple policies in the distribution itself. As long as you don't think you will ever need to support multiple translation libraries in the base distribution, then conflicting packages may be ok. Darrel, what do you think?

I personally like just managing the symlink /lib/libsetrans.so.0 to point
to whatever translation lib should be used. This allows for multiple
variations to be installed. As pointed out earlier, the alternatives
system could be used here. There should be no need to have more than one
translation scheme installed on a running system, but it may prove easier
to allow for that case. I think the question comes down to what is easier
for installing a system such as RHEL that may support multiple schemes such as MCS and MLS. Installing multiple policy types and switching between them is a nice feature. If the policies would want differing translation
schemes, I think it should be just as easy to switch - no rpm removal and installation.

Signature · 6 lines
Darrel

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#10 lore raw
Quoted 13 lines · Darrel Goeddel
Quoted 9 lines · Stephen Smalley
Quoted 1 line

I was thinking conflicting rpm packages. So You can not install MCS and MLS translation libaries at the same time.

Hmmm...I recall that you didn't want to take that approach for multiple policies, but in that case, you were providing multiple policies in the distribution itself. As long as you don't think you will ever need to support multiple translation libraries in the base distribution, then conflicting packages may be ok. Darrel, what do you think?

Quoted 10 lines

I personally like just managing the symlink /lib/libsetrans.so.0 to point
to whatever translation lib should be used. This allows for multiple
variations to be installed. As pointed out earlier, the alternatives
system could be used here. There should be no need to have more than one
translation scheme installed on a running system, but it may prove easier
to allow for that case. I think the question comes down to what is easier
for installing a system such as RHEL that may support multiple schemes such as MCS and MLS. Installing multiple policy types and switching between them is a nice feature. If the policies would want differing translation
schemes, I think it should be just as easy to switch - no rpm removal and installation.

I don't know, it seems like you will potentially have a different translation lib for different policies. The policy knows which it wants (MCS knows it'll want libsetrans-mls.so or whatever). If you have an MCS and an MLS policy on the same system part of the conversion shouldn't be changing a symlink, that is fairly hacky. This sounds like a per policy configuration to me. That way custom translation libs can be installed with the policy and the policy will use it by default.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#11 lore raw
In reply to Daniel J Walsh
Quoted 1 line · Daniel J Walsh

libselinux-rhat.patch is mainly tcs's patch with a couple of changes.

Do we truly need to allow whitespace in the (translated) MLS field? That change to context_new originated in the TCS patch, but I'd prefer to avoid it if possible.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#12 lore raw
Quoted 13 lines · Stephen Smalley
Quoted 3 lines · Daniel J Walsh

libselinux-rhat.patch is mainly tcs's patch with a couple of changes.

Do we truly need to allow whitespace in the (translated) MLS field? That change to context_new originated in the TCS patch, but I'd prefer to avoid it if possible.

I have no problem with not allowing spaces in translated name. We could come up with a third field, in the translation, Printable Name or some such, but that could come later...

Signature · 4 lines
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#13 lore raw
Quoted 15 lines · Daniel J Walsh
Quoted 13 lines · Stephen Smalley
Quoted 3 lines · Daniel J Walsh

libselinux-rhat.patch is mainly tcs's patch with a couple of changes.

Do we truly need to allow whitespace in the (translated) MLS field? That change to context_new originated in the TCS patch, but I'd prefer to avoid it if possible.

Quoted 3 lines

I have no problem with not allowing spaces in translated name. We could come up with a third field, in the translation, Printable Name or some such, but that could come later...

I'm just concerned about parsing code having to distinguish normal whitespace field separators (e.g. in ps or ls output) from internal separators within a label. If we allow whitespace within the context, we essentially have to start printing them all as quoted strings in all the utilities, as well as passing them that way as arguments.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#14 lore raw
Quoted 6 lines · Stephen Smalley
Quoted 5 lines · Daniel J Walsh
Quoted 4 lines

Do we truly need to allow whitespace in the (translated) MLS field? That change to context_new originated in the TCS patch, but I'd prefer to avoid it if possible.

Quoted 7 lines
Quoted 1 line

I have no problem with not allowing spaces in translated name. We could come up with a third field, in the translation, Printable Name or some such, but that could come later...

I'm just concerned about parsing code having to distinguish normal whitespace field separators (e.g. in ps or ls output) from internal separators within a label. If we allow whitespace within the context, we essentially have to start printing them all as quoted strings in all the utilities, as well as passing them that way as arguments.

Our MITRE based translator really like the whitespace... I agree that the whitespace is a pain, but we have been using this for quite a while and have not run into problems with any utilities that I am aware of. My biggest gripe is having to quote arguments to commands when a context has whitespace... How about we allow for it, and let those who choose to use whitespace (unfortunately our translation scheme) deal with the repercussions :)

Signature · 6 lines
Darrel

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#15 lore raw
Quoted 6 lines · Darrel Goeddel

Our MITRE based translator really like the whitespace... I agree that the whitespace is a pain, but we have been using this for quite a while and have not run into problems with any utilities that I am aware of. My biggest gripe is having to quote arguments to commands when a context has whitespace... How about we allow for it, and let those who choose to use whitespace (unfortunately our translation scheme) deal with the repercussions :)

I'm still concerned about the implications for utilities that display the contexts, and particularly for any scripts that filter output of such utilities and expect to be able to extract context fields. It seems like we'd need to quote the context strings in the output always to ensure that scripts won't break when someone switches from the default libsetrans to the MITRE-based one.

Alternatively, your MITRE-based translator could wrap the MITRE translation with a converter to eliminate whitespace (dropping it or replacing it with e.g. underscores), so that libselinux and the utilities (and users) would never have to deal with them.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#16 lore raw
In reply to Daniel J Walsh
Quoted 1 line · Daniel J Walsh

libselinux-rhat.patch is mainly tcs's patch with a couple of changes.

When I read through the patch, it looked sane. But a quick trial of ls -Z / showed a definite issue with no libsetrans in place. It generates garbage as soon as it hits a directory that doesn't support extended attributes.

This appears to reflect both a problem in the patch and a problem in ls. As far as the patch goes, when there is no libsetrans, the wrapper functions (e.g. getfilecon) are always setting *context to rcontext even if the raw function returned an error. I think we need to qualify the else clauses in the wrapper functions with if (ret > 0) as well so that we do not set *context to garbage when an error is encountered by the raw function. I can make that change.

As far as ls goes, it is presently not checking the return value of getfilecon/lgetfilecon; it just initializes the f->scontext pointers to NULL a priori and then passes them to getfilecon/lgetfilecon, assuming that they won't disturb them (or at least will reset them to NULL) upon any errors. It then checks for NULL at display time. That worked prior to the patch because the original function wouldn't set *context at all upon errors, but was broken by the patch when there was no libsetrans. It would be more robust to have ls check the return value and reset f->scontext to NULL upon any errors.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#17 lore raw
Quoted 7 lines · Stephen Smalley

This appears to reflect both a problem in the patch and a problem in ls. As far as the patch goes, when there is no libsetrans, the wrapper functions (e.g. getfilecon) are always setting *context to rcontext even if the raw function returned an error. I think we need to qualify the else clauses in the wrapper functions with if (ret > 0) as well so that we do not set *context to garbage when an error is encountered by the raw function. I can make that change.

This patch relative to the translation patch fixes the wrapper functions to not set the context pointers when the raw functions return an error. This fixes the problem with ls -Z displaying garbage when it encounters a file or directory with no extended attribute value.

I did notice one other issue with the translation patch that is not resolved by this one (in fact, this one propagates the same behavior to the !context_translations case). If getxattr returns a length of zero (shouldn't ever happen for the selinux attribute, but the interface allows for it), then the old getfilecon function would have set the context pointer to an empty buffer (containing only NULs) and returned zero as well. The wrapper functions don't presently set the context pointer at all in this case. Possibly we just shouldn't allow it to happen, i.e. return an error from the raw functions if we ever get a zero length from getxattr?

Index: libselinux/src/compute_create.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/compute_create.c,v retrieving revision 1.12

src/compute_create.c +1 -1
diff -u -p -r1.12 compute_create.c
@@ -87,7 +87,7 @@ int security_compute_create(security_con
 			}
 			freecon(rnewcon);
 		}
-	} else
+	} else if (!ret)
 		*newcon = rnewcon;
 
 	return ret;

Index: libselinux/src/compute_member.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/compute_member.c,v retrieving revision 1.2

src/compute_member.c +1 -1
diff -u -p -r1.2 compute_member.c
@@ -86,7 +86,7 @@ int security_compute_member(security_con
 			}
 			freecon(rnewcon);
 		}
-	} else
+	} else if (!ret)
 		*newcon = rnewcon;
 
 	return ret;

Index: libselinux/src/compute_relabel.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/compute_relabel.c,v retrieving revision 1.11

src/compute_relabel.c +1 -1
diff -u -p -r1.11 compute_relabel.c
@@ -86,7 +86,7 @@ int security_compute_relabel(security_co
 			}
 			freecon(rnewcon);
 		}
-	} else
+	} else if (!ret)
 		*newcon = rnewcon;
 
 	return ret;

Index: libselinux/src/fgetfilecon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/fgetfilecon.c,v retrieving revision 1.7

src/fgetfilecon.c +1 -1
diff -u -p -r1.7 fgetfilecon.c
@@ -57,7 +57,7 @@ int fgetfilecon(int fd, security_context
 			ret = -1;
 		}
 		freecon(rcontext);
-	} else
+	} else if (ret > 0)
 		*context = rcontext;
 
 	return ret;

Index: libselinux/src/getcon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/getcon.c,v retrieving revision 1.8

src/getcon.c +1 -1
diff -u -p -r1.8 getcon.c
@@ -57,7 +57,7 @@ int getcon(security_context_t *context)
 			ret = -1;
 		}
 		freecon(rcontext);
-	} else
+	} else if (!ret)
 		*context = rcontext;
 
 	return ret;

Index: libselinux/src/getexeccon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/getexeccon.c,v retrieving revision 1.6

src/getexeccon.c +1 -1
diff -u -p -r1.6 getexeccon.c
@@ -61,7 +61,7 @@ int getexeccon(security_context_t *conte
 			ret = -1;
 		}
 		freecon(rcontext);
-	} else
+	} else if (!ret)
 		*context = rcontext;
 
 	return ret;

Index: libselinux/src/getfilecon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/getfilecon.c,v retrieving revision 1.8

src/getfilecon.c +1 -1
diff -u -p -r1.8 getfilecon.c
@@ -58,7 +58,7 @@ int getfilecon(const char *path, securit
 			ret = -1;
 		}
 		freecon(rcontext);
-	} else
+	} else if (ret > 0)
 		*context = rcontext;
 
 	return ret;

Index: libselinux/src/getfscreatecon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/getfscreatecon.c,v retrieving revision 1.6

src/getfscreatecon.c +1 -1
diff -u -p -r1.6 getfscreatecon.c
@@ -61,7 +61,7 @@ int getfscreatecon(security_context_t *c
 			ret = -1;
 		}
 		freecon(rcontext);
-	} else
+	} else if (!ret)
 		*context = rcontext;
 
 	return ret;

Index: libselinux/src/getpeercon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/getpeercon.c,v retrieving revision 1.3

src/getpeercon.c +1 -1
diff -u -p -r1.3 getpeercon.c
@@ -56,7 +56,7 @@ int getpeercon(int fd, security_context_
 			ret = -1;
 		}
 		freecon(rcontext);
-	} else
+	} else if (!ret)
 		*context = rcontext;
 
 	return ret;

Index: libselinux/src/getpidcon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/getpidcon.c,v retrieving revision 1.5

src/getpidcon.c +1 -1
diff -u -p -r1.5 getpidcon.c
@@ -60,7 +60,7 @@ int getpidcon(pid_t pid, security_contex
 			ret = -1;
 		}
 		freecon(rcontext);
-	} else
+	} else if (!ret)
 		*context = rcontext;
 
 	return ret;

Index: libselinux/src/getprevcon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/getprevcon.c,v retrieving revision 1.6

src/getprevcon.c +1 -1
diff -u -p -r1.6 getprevcon.c
@@ -57,7 +57,7 @@ int getprevcon(security_context_t *conte
 			ret = -1;
 		}
 		freecon(rcontext);
-	} else
+	} else if (!ret)
 		*context = rcontext;
 
 	return ret;

Index: libselinux/src/lgetfilecon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/lgetfilecon.c,v retrieving revision 1.7

src/lgetfilecon.c +1 -1
diff -u -p -r1.7 lgetfilecon.c
@@ -57,7 +57,7 @@ int lgetfilecon(const char *path, securi
 			ret = -1;
 		}
 		freecon(rcontext);
-	} else
+	} else if (ret > 0)
 		*context = rcontext;
 
 	return ret;
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#18 lore raw
Quoted 9 lines · Stephen Smalley
Quoted 7 lines · Stephen Smalley

This appears to reflect both a problem in the patch and a problem in ls. As far as the patch goes, when there is no libsetrans, the wrapper functions (e.g. getfilecon) are always setting *context to rcontext even if the raw function returned an error. I think we need to qualify the else clauses in the wrapper functions with if (ret > 0) as well so that we do not set *context to garbage when an error is encountered by the raw function. I can make that change.

Quoted 4 lines

This patch relative to the translation patch fixes the wrapper functions to not set the context pointers when the raw functions return an error. This fixes the problem with ls -Z displaying garbage when it encounters a file or directory with no extended attribute value.

I've committed the libselinux translation support (including my fix patch). This is only the libselinux support; there is no libsetrans in our tree presently (and likely shouldn't be).

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#19 lore raw
Quoted 3 lines · Stephen Smalley

I've committed the libselinux translation support (including my fix patch). This is only the libselinux support; there is no libsetrans in our tree presently (and likely shouldn't be).

Note btw that you also need the procps patch posted by Chad Hanson on Aug 15th if you want ps to display the translated names.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#20 lore raw
In reply to Stephen Smalley

I still want at least the set_comp diff to allow me to set level to NULL, so it does not show up.

src/compute_relabel.c +1 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/compute_relabel.c libselinux-1.25.3/src/compute_relabel.c
@@ -20,6 +20,7 @@
 	size_t size;
 	int fd, ret;
 
+	*newcon=NULL;
 	snprintf(path, sizeof path, "%s/relabel", selinux_mnt);
 	fd = open(path, O_RDWR);
 	if (fd < 0)
src/compute_user.c +1 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/compute_user.c libselinux-1.25.3/src/compute_user.c
@@ -21,6 +21,7 @@
 	int fd, ret;
 	unsigned int i, nel;
 
+	*con = NULL;
 	snprintf(path, sizeof path, "%s/user", selinux_mnt);
 	fd = open(path, O_RDWR);
 	if (fd < 0)
src/context.c +15 -11
diff --exclude-from=exclude -N -u -r nsalibselinux/src/context.c libselinux-1.25.3/src/context.c
@@ -137,19 +137,23 @@
 
 static int set_comp(context_private_t* n,int index, const char *str)
 {
-        char *t = (char*) malloc(strlen(str)+1);
+        char *t = NULL;
         const char *p;
-        if ( !t ) { return 1; }
-        for ( p = str; *p; p++ ) {
-                if ( *p == '\t' || *p == ' ' || *p == '\n' || *p == '\r' ||
-                     (*p == ':' && index != COMP_RANGE) ) {
-                        free(t);
-                        return 1;
-                }
-        }
-        conditional_free(&n->component[index]);
+	if (str) {
+		t=(char*) malloc(strlen(str)+1);
+		if ( !t ) { return 1; }
+		for ( p = str; *p; p++ ) {
+			if ( *p == '\t' || *p == '\n' || *p == '\r' ||
+			     ((*p == ':' || *p == ' ') && index != COMP_RANGE) ) {
+				free(t);
+				return 1;
+			}
+		}
+	}
+	conditional_free(&n->component[index]);
+	if (str)
+		strcpy(t,str);
         n->component[index] = t;
-        strcpy(t,str);
         return 0;
 }
 
src/fgetfilecon.c +1 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/fgetfilecon.c libselinux-1.25.3/src/fgetfilecon.c
@@ -13,6 +13,7 @@
 	ssize_t size;
 	ssize_t ret;
 
+	*context = NULL;
 	size = INITCONTEXTLEN+1;
 	buf = malloc(size);
 	if (!buf) 
src/getcon.c +1 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getcon.c libselinux-1.25.3/src/getcon.c
@@ -14,6 +14,7 @@
 	int fd;
 	ssize_t ret;
 
+	*context=NULL;
 	fd = open("/proc/self/attr/current", O_RDONLY);
 	if (fd < 0)
 		return -1;
src/getexeccon.c +1 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getexeccon.c libselinux-1.25.3/src/getexeccon.c
@@ -14,6 +14,7 @@
 	int fd;
 	ssize_t ret;
 
+	*context = NULL;
 	fd = open("/proc/self/attr/exec", O_RDONLY);
 	if (fd < 0)
 		return -1;
src/getfilecon.c +1 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getfilecon.c libselinux-1.25.3/src/getfilecon.c
@@ -13,6 +13,7 @@
 	ssize_t size;
 	ssize_t ret;
 
+ 	*context = NULL;
 	size = INITCONTEXTLEN+1;
 	buf = malloc(size);
 	if (!buf) 
src/getfscreatecon.c +1 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getfscreatecon.c libselinux-1.25.3/src/getfscreatecon.c
@@ -14,6 +14,7 @@
 	int fd;
 	ssize_t ret;
 
+	*context = NULL;
 	fd = open("/proc/self/attr/fscreate", O_RDONLY);
 	if (fd < 0)
 		return -1;
src/getpeercon.c +1 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getpeercon.c libselinux-1.25.3/src/getpeercon.c
@@ -17,6 +17,7 @@
 	socklen_t size;
 	ssize_t ret;
 
+	*context = NULL;
 	size = INITCONTEXTLEN+1;
 	buf = malloc(size);
 	if (!buf) 
src/getpidcon.c +1 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getpidcon.c libselinux-1.25.3/src/getpidcon.c
@@ -16,6 +16,7 @@
 	int fd;
 	ssize_t ret;
 
+	*context = NULL;
 	snprintf(path, sizeof path, "/proc/%d/attr/current", pid);
 
 	fd = open(path, O_RDONLY);
src/getprevcon.c +1 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/getprevcon.c libselinux-1.25.3/src/getprevcon.c
@@ -14,6 +14,7 @@
 	int fd;
 	ssize_t ret;
 
+	*context = NULL;
 	fd = open("/proc/self/attr/prev", O_RDONLY);
 	if (fd < 0)
 		return -1;
src/lgetfilecon.c +1 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/src/lgetfilecon.c libselinux-1.25.3/src/lgetfilecon.c
@@ -13,6 +13,7 @@
 	ssize_t size;
 	ssize_t ret;
 
+	*context = NULL;
 	size = INITCONTEXTLEN+1;
 	buf = malloc(size);
 	if (!buf) 
src/trans.c +2 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/trans.c libselinux-1.25.3/src/trans.c
@@ -6,8 +6,8 @@
 
 int trans_to_raw_context(char *raw, char **transp)
 {
+	*transp = NULL;
 	if (!raw) {
-		*transp = NULL;
 		return 0;
 	}
 
@@ -19,8 +19,8 @@
 
 int raw_to_trans_context(char *trans, char **rawp)
 {
+	*rawp = NULL;
 	if (!trans) {
-		*rawp = NULL;
 		return 0;
 	}
 
utils/getfilecon.c +3 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/utils/getfilecon.c libselinux-1.25.3/utils/getfilecon.c
@@ -21,6 +21,9 @@
 		}
 		printf("%s\t%s\n", argv[i], buf);
 		freecon(buf);
+		rc = getfilecon_raw(argv[i], &buf);
+		printf("%s\t%s\n", argv[i], buf);
+		freecon(buf);
 	}
 	exit(0);
 }
#21 lore raw
Quoted 2 lines · Daniel J Walsh

I still want at least the set_comp diff to allow me to set level to NULL, so it does not show up.

Hmm...I dropped the set_comp diff entirely from the original patch because I didn't want the change to allow whitespace in the context, as per our earlier discussion on the list. I didn't notice that you were also changing it to allow NULL. Potential issue there is that your change would allow setting a NULL for any field, whereas context_str won't handle a NULL gracefully in any field other than the last.

With regard to clearing the context pointers on entry to the raw functions, I don't see why it is necessary given my earlier patch.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#22 lore raw
Quoted 7 lines · Stephen Smalley
Quoted 3 lines · Daniel J Walsh

I still want at least the set_comp diff to allow me to set level to NULL, so it does not show up.

Quoted 9 lines

Hmm...I dropped the set_comp diff entirely from the original patch because I didn't want the change to allow whitespace in the context, as per our earlier discussion on the list. I didn't notice that you were also changing it to allow NULL. Potential issue there is that your change would allow setting a NULL for any field, whereas context_str won't handle a NULL gracefully in any field other than the last.

Which is too bad since object_r is totally useless in ls output :^). Well we can either make sure it is that last field or not allow it. As I play with MCS, I am not sure whether we want this info or not, my problem with this field and object_r is that they give no info and take up a lot of screen space. (Although, probably an Engineer problem and not a real world problem.)

Quoted 5 lines

With regard to clearing the context pointers on entry to the raw functions, I don't see why it is necessary given my earlier patch.

Ok, you can forget about them.

Signature · 4 lines
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#23 lore raw

Ok I plead ignorance to the way MLS works.

In reply to Stephen Smalley

Playing around with MCS, I see the following problems.

Should the initialsid of kernel be

sid kernel system_u:system_r:kernel_t:s0:c0.c127
or
sid kernel system_u:system_r:kernel_t:s0 - s0:c0.c127

I would like all the daemon processes in the system to run as "s0", Ie by default not have access to any labeled
data. How do I do this? Am I supposed to use something like:
range_transition initrc_t httpd_exec_t s0 - s0;

Trying to use this is giving me a compilation error.

Signature · 4 lines
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#24 lore raw

Re: Ok I plead ignorance to the way MLS works.

Quoted 8 lines · Daniel J Walsh

Playing around with MCS, I see the following problems.

Should the initialsid of kernel be

sid kernel system_u:system_r:kernel_t:s0:c0.c127
or
sid kernel system_u:system_r:kernel_t:s0 - s0:c0.c127

Quoted 5 lines

I would like all the daemon processes in the system to run as "s0", Ie by default not have access to any labeled
data. How do I do this? Am I supposed to use something like:
range_transition initrc_t httpd_exec_t s0 - s0;

Trying to use this is giving me a compilation error.

I think you would want to run the kernel would at s0:c0.c127. Then, do a "range_transition kernel_t init_exec_t s0" to get the whole of userspace started off with no categories present. This is a change from the range_transition that is ifdef'd currently for mls in kernel.te. Are you going to have "ifdef mcs_policy" like the current "ifdef mls_policy"?

I'm sure about the compilation error, I did a similar statement with a toolchain that is are pre-modules - that worked. I'm updating an FC4 box now so I at least have something up-to-date.

Signature · 6 lines
Darrel

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#25 lore raw

Re: Ok I plead ignorance to the way MLS works.

Quoted 3 lines · Darrel Goeddel

I think you would want to run the kernel would at s0:c0.c127. Then, do a "range_transition kernel_t init_exec_t s0" to get the whole of userspace started off with no categories present.

Why not just have the kernel start out at s0 (no categories), and just give its domain the necessary attributes to override MLS? Then you don't need to transition at all. Otherwise, you also have to deal with any other kernel-invoked helpers, e.g. hotplug.

Quoted 3 lines

I'm sure about the compilation error, I did a similar statement with a toolchain that is are pre-modules - that worked. I'm updating an FC4 box now so I at least have something up-to-date.

I just tried adding the range_transition listed by Dan to a policy.conf and rebuilding with checkpolicy -M (latest cvs), and it worked for me. But note that s0 - s0 is unnecessary; it is the same as just s0. The high level defaults to the low level if it isn't specified.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#26 lore raw

Re: Ok I plead ignorance to the way MLS works.

Quoted 9 lines · Stephen Smalley
Quoted 5 lines · Darrel Goeddel

I think you would want to run the kernel would at s0:c0.c127. Then, do a "range_transition kernel_t init_exec_t s0" to get the whole of userspace started off with no categories present.

Quoted 7 lines

Why not just have the kernel start out at s0 (no categories), and just give its domain the necessary attributes to override MLS? Then you don't need to transition at all. Otherwise, you also have to deal with any other kernel-invoked helpers, e.g. hotplug.

Ok, I changed the kernel to s0, and now all domains run in s0. Problem is I want root to login as s0:c0.c127

I changed root default context file (/etc/selinux/targeted/contexts/users/root) to

system_u:system_r:local_login_t:s0 system_r:unconfined_t:s0:c0.c127

But when I login I get

root:system_r:unconfined_t:s0

login is running as
system_u:system_r:local_login_t:s0

Should it be running with a range?
Do I need to change login policy?
I see no errors...

Quoted 6 lines
Quoted 5 lines

I'm sure about the compilation error, I did a similar statement with a toolchain that is are pre-modules - that worked. I'm updating an FC4 box now so I at least have something up-to-date.

Quoted 7 lines

I just tried adding the range_transition listed by Dan to a policy.conf and rebuilding with checkpolicy -M (latest cvs), and it worked for me. But note that s0 - s0 is unnecessary; it is the same as just s0. The high level defaults to the low level if it isn't specified.

Ok it was within a boolean block.

Signature · 4 lines
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#27 lore raw

Re: Ok I plead ignorance to the way MLS works.

Quoted 11 lines · Daniel J Walsh

Ok, I changed the kernel to s0, and now all domains run in s0. Problem is I want root to login as
s0:c0.c127

I changed root default context file
(/etc/selinux/targeted/contexts/users/root) to

system_u:system_r:local_login_t:s0 system_r:unconfined_t:s0:c0.c127

But when I login I get

Quoted 8 lines

root:system_r:unconfined_t:s0

login is running as
system_u:system_r:local_login_t:s0

Should it be running with a range?
Do I need to change login policy?
I see no errors...

Hmmm...looks like you have to transition login to a range via a range_transition rule on login_exec_t in order for the current MLS logic to permit the user to login at a different level.

Also, I think you want root's default level to still be s0, but his range to be s0-s0:c0.c127, so that his clearance will be set to that value. You want the current/low level to be s0 so that files he creates default to no categories, but his high/clearance level to be his authorized set of categories so that he is allowed by the MCS constraints to set any of those categories on files he owns.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#28 lore raw

Re: Ok I plead ignorance to the way MLS works.

In reply to Daniel J Walsh
Quoted 4 lines · Daniel J Walsh

Ok, I changed the kernel to s0, and now all domains run in s0. Problem is I want root to login as
s0:c0.c127

This will cause all of the files created by root to be labeled with all categories.

- James

Signature · 7 lines
James Morris
<[email protected]>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#29 lore raw
In reply to Daniel J Walsh
Quoted 2 lines · Daniel J Walsh

I still want at least the set_comp diff to allow me to set level to NULL, so it does not show up.

How about this patch? Changes set_comp to allow setting to NULL, but doesn't allow whitespace in the context. Also changes context_str to be somewhat more general, but context_new is still not going to like a context that lacks any field other than the level, and the kernel won't take a partial one.

Index: libselinux/src/context.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/context.c,v retrieving revision 1.10

src/context.c +22 -19
diff -u -p -r1.10 context.c
@@ -119,15 +119,15 @@ context_str(context_t context)
         }
         n->current_str = malloc(total);
         if ( n->current_str != 0 ) {
-                char *cp = stpcpy(n->current_str,n->component[0]);
-                *cp++ = ':';
-                cp = stpcpy(cp,n->component[1]);
-                *cp++ = ':';
-                cp = stpcpy(cp,n->component[2]);
-                if ( n->component[3] ) {
-                        *cp++ = ':';
-                        strcpy(cp,n->component[3]);
-                }
+                char *cp = n->current_str;
+
+		cp = stpcpy(cp, n->component[0]);
+		for (i = 1; i < 4; i++) {
+			if (n->component[i]) {
+				*cp++ = ':';
+				cp = stpcpy(cp, n->component[i]);
+			}
+		}
         }
         return n->current_str;
 }
@@ -137,19 +137,22 @@ hidden_def(context_str)
 
 static int set_comp(context_private_t* n,int index, const char *str)
 {
-        char *t = (char*) malloc(strlen(str)+1);
+	char *t = NULL;
         const char *p;
-        if ( !t ) { return 1; }
-        for ( p = str; *p; p++ ) {
-                if ( *p == '\t' || *p == ' ' || *p == '\n' || *p == '\r' ||
-                     (*p == ':' && index != COMP_RANGE) ) {
-                        free(t);
-                        return 1;
-                }
-        }
+	if (str) {
+		t = (char*) malloc(strlen(str)+1);
+		if ( !t ) { return 1; }
+		for ( p = str; *p; p++ ) {
+			if ( *p == '\t' || *p == ' ' || *p == '\n' || *p == '\r' ||
+			     (*p == ':' && index != COMP_RANGE) ) {
+				free(t);
+				return 1;
+			}
+		}
+		strcpy(t,str);
+	}
         conditional_free(&n->component[index]);
         n->component[index] = t;
-        strcpy(t,str);
         return 0;
 }
 
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#30 lore raw
In reply to Stephen Smalley

Updated setrans.c to handle s0 and multiple categories.

#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <selinux/selinux.h>
#include <selinux/context.h>

#define CATEGORYFILE "/etc/secat.conf"

/* Define data structures */

typedef struct selevel {
	char* name;
	char* sename;
} selevel_t;

/* catlist is a simple linked list of selevels extracted from the CATEGORYFILE */

typedef struct cat {
	struct cat *next;
	selevel_t level;
} cat_t;

static cat_t *catlist=NULL;

/* Remove excess white space */

static char *strtrim(char *dest, char *source, int size) {
	int i=0;
	char *ptr=source;
	i=0;
	while(isspace(*ptr) && i < size) {
		ptr++;
		i++;
	}
	strncpy(dest,ptr,size);
	for(i=strlen(dest)-1; i> 0; i--) {
		if (!isspace(dest[i])) break;
	}
	dest[i+1]='\0';
	return dest;
}
/* Process line from CATEGORYFILE. 
   Remove white space and set name do data before the "=" and sename to data
   after it */
static int process_category(char *buffer, cat_t **cat) {
	char name[BUFSIZ];
	char name1[BUFSIZ];
	int namesize=sizeof(name);
	struct cat *next;
	char *ptr;
	char *tok=strtok_r(buffer,"=",&ptr);
	if (!tok) return 0;
	strncpy(name1,tok, BUFSIZ-1);
	strtrim(name,name1,namesize-1);
	if ( name[0]=='#' ) return 0;
	tok=strtok_r(NULL,"\0",&ptr);
	if (!tok) return 0;
	while (isspace(*tok)) tok++;
	next=(cat_t *) calloc(sizeof(cat_t), 1);
	if (!next) return 0;
	next->level.name=strdup(name);
	if (!next->level.name) {
		free(next);
		return 0;
	}
	strncpy(name1,tok, BUFSIZ-1);
	strtrim(name,name1,namesize-1);
	next->level.sename=strdup(name);
	if (!next->level.sename) {
		free(next->level.name);
		free(next);
		return 0;
	}
	*cat=next;
	return 1;
}

/* Read in CATEGORYFILE Only runs once per process.
Might want to change to some kind of reload eventually, for long running processes.
*/

int init_context_translations(void) {
	FILE *cfg;
	cat_t *ptr=NULL;
	cat_t *next=NULL;
	size_t size=0;
	char *buffer=NULL;
	int ctr=0;
	if (catlist) return 0;
	cfg = fopen(CATEGORYFILE,"r");
	if (cfg == NULL) 
		return 1;

	ptr=catlist=calloc(1,sizeof(cat_t));
	while (getline(&buffer, &size, cfg) > 0) {
		if (process_category(buffer, &next)) {
			ctr++;
			ptr->next=next;
			ptr=next;
		}
	}
	if (buffer)
		free(buffer);
	return 0;
}

/* Look for selevel via internal name */

static char *translate(const char *cat) {
	cat_t *ptr=NULL;
	if (catlist) 
		for (ptr=catlist->next;ptr; ptr=ptr->next) 
			if (strcmp(cat,ptr->level.name)==0) {
				if (strlen(ptr->level.sename)==0)
					return NULL;
				else
					return strdup(ptr->level.sename); 
			}
	return strdup(cat);
}

/* Look for selevel via external name */

static char *untranslate(const char *sename) {
	cat_t *ptr=NULL;
	if (catlist) 
		for(ptr=catlist->next;ptr; ptr=ptr->next)
			if (strcmp(sename,ptr->level.sename)==0) {
				char *buf=calloc(strlen(ptr->level.name+4),1);
				if (buf) 
					sprintf(buf, "s0:%s",ptr->level.name); 
				return buf; 
			}
	return strdup(sename);
}

/* Look for selevel via external name */

int translate_context( const security_context_t oldcon, security_context_t *rcon) {
	const char *range=NULL;
	const char *ptr=NULL;
	context_t con=context_new(oldcon);

	if (! con)
		return -1;

	range=context_range_get(con);
	if (range) {
		ptr=strrchr(range,':');
		if (ptr) 
			ptr++;
		else
			ptr=range;
		context_range_set(con,translate(ptr));
	}
	*rcon=strdup(context_str(con));
	context_free(con);
	return 0;
}

/* Look for selevel via external name */

int untranslate_context( const security_context_t oldcon, security_context_t *rcon) {
	const char *range=NULL;
	char *newrange=NULL;
	context_t con=context_new(oldcon);

	if (! con)
		return -1;

	range=context_range_get(con);
	if (range) {
		newrange=untranslate(range);
		if (newrange) {
			context_range_set(con,newrange);
		}
	}
	*rcon=strdup(context_str(con));
	context_free(con);
	return 0;
}

#
# Multiple Category System translation table for SELinux
#
# Sensitivities s0= should not be modified
# Objects can be categorized with 0-127 categories defined by the admin. # Objects can be in more then one categories at a time.
# Categories are stored in the system as c0-c127. Users can use this

# table to translate the categories into a more meaningfull output.
# Examples:
# c0=CompanyConfidential
# c1=PatientRecord
# c2=Unclassified
# c3=TopSecret
# c1,c3=CompanyConfidentialRedHat
s0=
#31 lore raw
In reply to Daniel J Walsh
Quoted 1 line · Daniel J Walsh

libselinux-rhat.patch is mainly tcs's patch with a couple of changes.

Hide the translation-related symbols entirely, as they are only used internally, and provide hidden definitions of the raw functions so that their internal use by libselinux is always satisfied locally. See
http://people.redhat.com/drepper/dsohowto.pdf

Index: libselinux/src/booleans.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/booleans.c,v retrieving revision 1.18

src/booleans.c +1 -0
diff -u -p -r1.18 booleans.c
@@ -165,6 +165,7 @@ int security_get_boolean_active(const ch
 	free(buf);
 	return val;
 }
+hidden_def(security_get_boolean_active)
 
 int security_set_boolean(const char *name, int value)
 {

Index: libselinux/src/checkAccess.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/checkAccess.c,v retrieving revision 1.4

src/checkAccess.c +1 -0
diff -u -p -r1.4 checkAccess.c
@@ -31,6 +31,7 @@ int selinux_check_passwd_access(access_v
         
         return status;
 }
+hidden_def(selinux_check_passwd_access)
 
 int checkPasswdAccess(access_vector_t requested) {
        return selinux_check_passwd_access(requested);

Index: libselinux/src/compute_member.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/compute_member.c,v retrieving revision 1.3

src/compute_member.c +1 -0
diff -u -p -r1.3 compute_member.c
@@ -54,6 +54,7 @@ out:
 	close(fd);
 	return ret;
 }
+hidden_def(security_compute_member_raw)
 
 int security_compute_member(security_context_t scon,
                             security_context_t tcon,

Index: libselinux/src/compute_relabel.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/compute_relabel.c,v retrieving revision 1.12

src/compute_relabel.c +1 -0
diff -u -p -r1.12 compute_relabel.c
@@ -54,6 +54,7 @@ out:
 	close(fd);
 	return ret;
 }
+hidden_def(security_compute_relabel_raw)
 
 int security_compute_relabel(security_context_t scon,
                              security_context_t tcon,

Index: libselinux/src/fgetfilecon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/fgetfilecon.c,v retrieving revision 1.8

src/fgetfilecon.c +1 -0
diff -u -p -r1.8 fgetfilecon.c
@@ -43,6 +43,7 @@ out:			
 		*context = buf;
 	return ret;
 }
+hidden_def(fgetfilecon_raw)
 
 int fgetfilecon(int fd, security_context_t *context)
 {

Index: libselinux/src/fsetfilecon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/fsetfilecon.c,v retrieving revision 1.3

src/fsetfilecon.c +1 -0
diff -u -p -r1.3 fsetfilecon.c
@@ -11,6 +11,7 @@ int fsetfilecon_raw(int fd, security_con
 {
 	return fsetxattr(fd, XATTR_NAME_SELINUX, context, strlen(context)+1, 0);
 }
+hidden_def(setfilecon_raw)
 
 int fsetfilecon(int fd, security_context_t context)
 {

Index: libselinux/src/getexeccon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/getexeccon.c,v retrieving revision 1.7

src/getexeccon.c +1 -0
diff -u -p -r1.7 getexeccon.c
@@ -47,6 +47,7 @@ out:
 	close(fd);
 	return ret;
 }
+hidden_def(getexeccon_raw)
 
 int getexeccon(security_context_t *context)
 {

Index: libselinux/src/getfscreatecon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/getfscreatecon.c,v retrieving revision 1.7

src/getfscreatecon.c +1 -0
diff -u -p -r1.7 getfscreatecon.c
@@ -47,6 +47,7 @@ out:
 	close(fd);
 	return ret;
 }
+hidden_def(getfscreatecon_raw)
 
 int getfscreatecon(security_context_t *context)
 {

Index: libselinux/src/getpeercon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/getpeercon.c,v retrieving revision 1.4

src/getpeercon.c +1 -0
diff -u -p -r1.4 getpeercon.c
@@ -42,6 +42,7 @@ out:			
 		*context = buf;
 	return ret;
 }
+hidden_def(getpeercon_raw)
 
 int getpeercon(int fd, security_context_t *context)
 {

Index: libselinux/src/getpidcon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/getpidcon.c,v retrieving revision 1.6

src/getpidcon.c +1 -0
diff -u -p -r1.6 getpidcon.c
@@ -46,6 +46,7 @@ out:
 	close(fd);
 	return ret;
 }
+hidden_def(getpidcon_raw)
 
 int getpidcon(pid_t pid, security_context_t *context)
 {

Index: libselinux/src/init.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/init.c,v retrieving revision 1.11

src/init.c +6 -4
diff -u -p -r1.11 init.c
@@ -9,6 +9,7 @@
 #include <stdio.h>
 #include <dlfcn.h>
 
+#include "dso.h"
 #include "policy.h"
 
 char *selinux_mnt = NULL;
@@ -73,11 +74,12 @@ void set_selinuxmnt(char *mnt)
 	selinux_mnt = strdup(mnt);
 }
  
-int context_translations = 0;
-void *translation_lib_handle = NULL;
+int context_translations hidden;
+void *translation_lib_handle hidden;
+
 /* from libsetrans.c */
-extern int (*lib_trans_to_raw_context)(char *trans, char **rawp);
-extern int (*lib_raw_to_trans_context)(char *raw, char **transp);
+extern int hidden (*lib_trans_to_raw_context)(char *trans, char **rawp);
+extern int hidden (*lib_raw_to_trans_context)(char *raw, char **transp);
 
 
 static void init_translations(void)

Index: libselinux/src/lgetfilecon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/lgetfilecon.c,v retrieving revision 1.8

src/lgetfilecon.c +1 -0
diff -u -p -r1.8 lgetfilecon.c
@@ -43,6 +43,7 @@ out:			
 		*context = buf;
 	return ret;
 }
+hidden_def(lgetfilecon_raw)
 
 int lgetfilecon(const char *path, security_context_t *context)
 {

Index: libselinux/src/lsetfilecon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/lsetfilecon.c,v retrieving revision 1.3

src/lsetfilecon.c +1 -0
diff -u -p -r1.3 lsetfilecon.c
@@ -11,6 +11,7 @@ int lsetfilecon_raw(const char *path, se
 {
 	return lsetxattr(path, XATTR_NAME_SELINUX, context, strlen(context)+1, 0);
 }
+hidden_def(lsetfilecon_raw)
 
 int lsetfilecon(const char *path, security_context_t context)
 {

Index: libselinux/src/selinux_internal.h
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/selinux_internal.h,v retrieving revision 1.8

src/selinux_internal.h +18 -3
diff -u -p -r1.8 selinux_internal.h
@@ -1,6 +1,7 @@
 #include <selinux/selinux.h>
 #include "dso.h"
 
+hidden_proto(security_get_boolean_active)
 hidden_proto(security_set_boolean)
 hidden_proto(security_commit_booleans)
 hidden_proto(security_check_context)
@@ -11,6 +12,8 @@ hidden_proto(security_compute_user)
 hidden_proto(security_compute_user_raw)
 hidden_proto(security_compute_create)
 hidden_proto(security_compute_create_raw)
+hidden_proto(security_compute_member_raw)
+hidden_proto(security_compute_relabel_raw)
 hidden_proto(is_selinux_enabled)
 hidden_proto(is_selinux_mls_enabled)
 hidden_proto(freecon)
@@ -19,10 +22,21 @@ hidden_proto(getprevcon)
 hidden_proto(getprevcon_raw)
 hidden_proto(getcon)
 hidden_proto(getcon_raw)
+hidden_proto(setcon_raw)
+hidden_proto(getpeercon_raw)
+hidden_proto(getpidcon_raw)
+hidden_proto(getexeccon_raw)
 hidden_proto(getfilecon)
 hidden_proto(getfilecon_raw)
+hidden_proto(lgetfilecon_raw)
+hidden_proto(fgetfilecon_raw)
+hidden_proto(setfilecon_raw)
+hidden_proto(lsetfilecon_raw)
+hidden_proto(fsetfilecon_raw)
 hidden_proto(setexeccon)
 hidden_proto(setexeccon_raw)
+hidden_proto(getfscreatecon_raw)
+hidden_proto(setfscreatecon_raw)
 hidden_proto(security_getenforce)
 hidden_proto(selinux_default_context_path)
 hidden_proto(selinux_failsafe_context_path)
@@ -32,9 +46,10 @@ hidden_proto(selinux_user_contexts_path)
 hidden_proto(selinux_booleans_path)
 hidden_proto(selinux_customizable_types_path)
 hidden_proto(selinux_media_context_path)
+hidden_proto(selinux_check_passwd_access)
 hidden_proto(matchpathcon_init)
 hidden_proto(selinux_users_path)
 
-extern int context_translations;
-extern int trans_to_raw_context(char *trans, char **rawp);
-extern int raw_to_trans_context(char *raw, char **transp);
+extern int context_translations hidden;
+extern int hidden trans_to_raw_context(char *trans, char **rawp);
+extern int hidden raw_to_trans_context(char *raw, char **transp);

Index: libselinux/src/setcon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/setcon.c,v retrieving revision 1.2

src/setcon.c +1 -0
diff -u -p -r1.2 setcon.c
@@ -25,6 +25,7 @@ int setcon_raw(security_context_t contex
 	else
 		return 0;
 }
+hidden_def(setcon_raw)
 
 int setcon(char *context)
 {

Index: libselinux/src/setfilecon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/setfilecon.c,v retrieving revision 1.3

src/setfilecon.c +1 -0
diff -u -p -r1.3 setfilecon.c
@@ -11,6 +11,7 @@ int setfilecon_raw(const char *path, sec
 {
 	return setxattr(path, XATTR_NAME_SELINUX, context, strlen(context)+1, 0);
 }
+hidden_def(setfilecon_raw)
 
 int setfilecon(const char *path, security_context_t context)
 {

Index: libselinux/src/setfscreatecon.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/setfscreatecon.c,v retrieving revision 1.5

src/setfscreatecon.c +1 -0
diff -u -p -r1.5 setfscreatecon.c
@@ -21,6 +21,7 @@ int setfscreatecon_raw(char *context)
 	else
 		return 0;
 }
+hidden_def(setfscreatecon_raw)
 
 int setfscreatecon(char *context)
 {

Index: libselinux/src/trans.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/trans.c,v retrieving revision 1.3

src/trans.c +4 -4
diff -u -p -r1.3 trans.c
@@ -1,10 +1,10 @@
 #include "selinux_internal.h"
 #include <string.h>
 
-int (*lib_trans_to_raw_context)(char *trans, char **rawp) = NULL;
-int (*lib_raw_to_trans_context)(char *raw, char **transp) = NULL;
+int (*lib_trans_to_raw_context)(char *trans, char **rawp) hidden;
+int (*lib_raw_to_trans_context)(char *raw, char **transp) hidden;
 
-int trans_to_raw_context(char *trans, char **rawp)
+int hidden trans_to_raw_context(char *trans, char **rawp)
 {
 	*rawp = NULL;
 	if (!trans)
@@ -16,7 +16,7 @@ int trans_to_raw_context(char *trans, ch
 	return *rawp ? 0 : -1;
 }
 
-int raw_to_trans_context(char *raw, char **transp)
+int hidden raw_to_trans_context(char *raw, char **transp) 
 {
 	*transp = NULL;
 	if (!raw)
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.