Skip to contentSkip to conversation

enforcing mode

DISCUSSION Carsten Grohmann 2 participants 3 messages Apr 26, 2002 – May 16, 2002 SELinux security module

lore
Share & tools
lore
#0 lore raw

Greeting,

this time I use SELinux and after each start it is run in the permissive mode. After each start I change manual to the enforcing mode. It is possible to start automatic in the enforcing Mode? Or need I a script to do this?

Thanks

Carsten

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 4 lines · Carsten Grohmann

this time I use SELinux and after each start it is run in the permissive mode. After each start I change manual to the enforcing mode. It is possible to start automatic in the enforcing Mode? Or need I a script to do this?

This is discussed in step 20 of selinux/README and in the kernel configuration help text for the SELinux Development Module option. Quoting from README:

Once you are satisfied that your policy configuration is sufficient for your system, you should either run avc_toggle from an rc script to switch into enforcing mode during initialization, or you should rebuild the kernel without this option [SELinux Development Module] so that it is always in enforcing mode. The first option leaves open the possibility of switching back to permissive mode by an administrator, while the latter option provides stricter security. If you choose the latter option, be sure to keep a kernel that is built with the Development Module option available for emergency recovery (e.g. if you make an error in your policy configuration that renders your system unuseable).

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux 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
In reply to Carsten Grohmann
Quoted 4 lines · Carsten Grohmann

this time I use SELinux and after each start it is run in the permissive mode. After each start I change manual to the enforcing mode. It is possible to start automatic in the enforcing Mode? Or need I a script to do this?

The attached patch (also committed to sourceforge CVS) allows enforcing mode to be selected at boot time (if built-in) or module insertion time if SELinux was built with the development option. Use "enforcing=1" on the kernel command line to start in enforcing mode. Of course, you can also build SELinux without the development option to cause it to always operate in enforcing mode.

--
Stephen D. Smalley, NAI Labs
[email protected]

Index: security/selinux/hooks.c
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.4/security/selinux/hooks.c,v retrieving revision 1.7
retrieving revision 1.8

selinux/hooks.c +27 -0
diff -u -r1.7 -r1.8
@@ -5100,6 +5100,23 @@
 
 static long (*orig_syscall)(void);
 
+#ifdef CONFIG_SECURITY_SELINUX_DEVELOP
+static int enforcing = 0;
+
+#ifdef MODULE
+MODULE_PARM(enforcing, "i");
+MODULE_PARM_DESC(enforcing, "SELinux:  Start in enforcing mode");
+#else
+static int __init enforcing_setup(char *str)
+{
+	enforcing = simple_strtol(str,NULL,0);
+	return 1;
+}
+__setup("enforcing=", enforcing_setup);
+#endif
+
+#endif
+
 static int __init selinux_plug_init (void)
 {
 	int rc = 0;
@@ -5143,6 +5160,16 @@
 	}
 
 	printk (KERN_INFO "SELinux:  module inserted\n");
+
+#ifdef CONFIG_SECURITY_SELINUX_DEVELOP
+	if (enforcing) {
+		printk(KERN_INFO "SELinux:  Starting in enforcing mode\n");
+		avc_debug_always_allow = 0;
+	} else {
+		printk(KERN_INFO "SELinux:  Starting in permissive mode\n");
+		avc_debug_always_allow = 1;
+	}
+#endif
 
 	return rc;
 }