Skip to contentSkip to conversation

patch for is_selinux_enabled()

PATCH Russell Coker 1 participant 1 message Aug 27, 2003 SELinux security module

lore
Share & tools
lore
#0 lore raw

The attached patch makes getcon() (and therefore is_selinux_enabled()) fail when you boot a SE enabled kernel but don't load a policy.

This gives the same result as a change Steve made to the old SE kernel patch some time ago. With this patch if you have installed the PAM module for SE Linux support (or a modified login/sshd) and a kernel but not the policy then you can still boot the machine and login.

Otherwise booting a SE kernel with patched applications but without a policy loaded gives you an unusable system that you can't login to.

Also as a side-affect of this patch programs such as ps and ls will operate as if they are on a non-SE system if you boot without policy loaded (which I consider to be desirable behavior).

Signature · 4 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page
src/getcon.c +5 -0
diff -ruN libselinux-1.1.orig/src/getcon.c libselinux-1.1/src/getcon.c
@@ -29,6 +29,11 @@
 	ret = read(fd, buf, size-1);
 	if (ret < 0)
 		goto out2;
+	if(!strcmp(buf, "kernel"))
+	{
+		ret = -1;
+		goto out2;
+	}
 
 	*context = strdup(buf);
 	if (!(*context)) {