Patch from Jason Schoon to add optional SIGUSR1 support to dd.
[oweals/busybox.git] / init / init.c
index 704cfccda16fe48ea1eb2f0db2c99a319fc73978..22fb33dfd8d3a5b8d07215d072a69f97dfa3079e 100644 (file)
@@ -24,7 +24,7 @@
 #include <termios.h>
 #include <unistd.h>
 #include <limits.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #endif
 
 
+#ifdef CONFIG_SELINUX
+# include <selinux/selinux.h>
+#endif /* CONFIG_SELINUX */
+
+
 #define INIT_BUFFS_SIZE 256
 
 /* From <linux/vt.h> */
@@ -1097,6 +1102,22 @@ int init_main(int argc, char **argv)
                parse_inittab();
        }
 
+#ifdef CONFIG_SELINUX
+       if (getenv("SELINUX_INIT") == NULL) {
+               int enforce = 0;
+
+               putenv("SELINUX_INIT=YES");
+               if (selinux_init_load_policy(&enforce) == 0) {
+                       execv(argv[0], argv);
+               } else if (enforce > 0) {
+                       /* SELinux in enforcing mode but load_policy failed */
+                       /* At this point, we probably can't open /dev/console, so log() won't work */
+                       message(CONSOLE,"Unable to load SELinux Policy. Machine is in enforcing mode. Halting now.");
+                       exit(1);
+               }
+       }
+#endif /* CONFIG_SELINUX */
+
        /* Make the command line just say "init"  -- thats all, nothing else */
        fixup_argv(argc, argv, "init");