diff -ur sysvinit-2.86.org/src/init.c sysvinit-2.86/src/init.c --- sysvinit-2.86.org/src/init.c 2004-07-30 14:16:20.000000000 +0200 +++ sysvinit-2.86/src/init.c 2005-12-24 23:22:51.000000000 +0100 @@ -42,6 +42,8 @@ #include #include #include +#include + #ifdef __i386__ # if (__GLIBC__ >= 2) @@ -2599,6 +2601,7 @@ char *p; int f; int isinit; + int enforce = 0; /* Get my own name */ if ((p = strrchr(argv[0], '/')) != NULL) @@ -2662,6 +2665,20 @@ maxproclen += strlen(argv[f]) + 1; } + if (getenv("SELINUX_INIT") == NULL) { + putenv("SELINUX_INIT=YES"); + if (selinux_init_load_policy(&enforce) == 0 ) { + execv(myname, 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 */ + initlog(L_VB,"Unable to load SELinux Policy. Machine is in enforcing mode. Halting now."); + exit(1); + } + } + } + /* Start booting. */ argv0 = argv[0]; argv[1] = NULL; diff -ur sysvinit-2.86.org/src/Makefile sysvinit-2.86/src/Makefile --- sysvinit-2.86.org/src/Makefile 2005-12-24 23:21:59.000000000 +0100 +++ sysvinit-2.86/src/Makefile 2005-12-24 23:23:14.000000000 +0100 @@ -58,7 +58,7 @@ all: $(BIN) $(SBIN) $(USRBIN) init: init.o init_utmp.o - $(CC) $(LDFLAGS) $(STATIC) -o $@ init.o init_utmp.o + $(CC) $(LDFLAGS) $(STATIC) -o $@ init.o init_utmp.o -lsepol -lselinux halt: halt.o ifdown.o hddown.o utmp.o reboot.h $(CC) $(LDFLAGS) -o $@ halt.o ifdown.o hddown.o utmp.o @@ -79,7 +79,7 @@ $(CC) $(LDFLAGS) -o $@ runlevel.o sulogin: sulogin.o md5_broken.o md5_crypt_broken.o arc4random.o bcrypt.o blowfish.o - $(CC) $(LDFLAGS) $(STATIC) -o $@ $^ $(LCRYPT) + $(CC) $(LDFLAGS) $(STATIC) -o $@ $^ $(LCRYPT) -lselinux wall: dowall.o wall.o $(CC) $(LDFLAGS) -o $@ dowall.o wall.o diff -ur sysvinit-2.86.org/src/sulogin.c sysvinit-2.86/src/sulogin.c --- sysvinit-2.86.org/src/sulogin.c 2005-12-24 23:21:59.000000000 +0100 +++ sysvinit-2.86/src/sulogin.c 2005-12-24 23:23:33.000000000 +0100 @@ -30,6 +30,9 @@ #include "md5.h" #include "blowfish.h" +#include +#include + #define CHECK_DES 1 #define CHECK_MD5 1 #define CHECK_BLOWFISH 1 @@ -362,6 +365,19 @@ signal(SIGINT, SIG_DFL); signal(SIGTSTP, SIG_DFL); signal(SIGQUIT, SIG_DFL); + if (is_selinux_enabled > 0) { + security_context_t scon=NULL; + char *seuser=NULL; + char *level=NULL; + if (getseuserbyname("root", &seuser, &level) == 0) + if (get_default_context_with_level(seuser, level, 0, &scon) > 0) { + if (setexeccon(scon) != 0) + fprintf(stderr, "setexeccon faile\n"); + freecon(scon); + } + free(seuser); + free(level); + } execl(sushell, shell, NULL); perror(sushell);