]> git.pld-linux.org Git - packages/SysVinit.git/blob - sysvinit-selinux.patch
- much simpler version
[packages/SysVinit.git] / sysvinit-selinux.patch
1 diff -ur sysvinit-2.86.org/src/init.c sysvinit-2.86/src/init.c
2 --- sysvinit-2.86.org/src/init.c        2004-07-30 14:16:20.000000000 +0200
3 +++ sysvinit-2.86/src/init.c    2005-12-24 23:22:51.000000000 +0100
4 @@ -42,6 +42,8 @@
5  #include <stdarg.h>
6  #include <sys/syslog.h>
7  #include <sys/time.h>
8 +#include <selinux/selinux.h>
9 +
10  
11  #ifdef __i386__
12  #  if (__GLIBC__ >= 2)
13 @@ -2599,6 +2601,7 @@
14         char                    *p;
15         int                     f;
16         int                     isinit;
17 +       int                     enforce = 0;
18  
19         /* Get my own name */
20         if ((p = strrchr(argv[0], '/')) != NULL)
21 @@ -2662,6 +2665,20 @@
22                 maxproclen += strlen(argv[f]) + 1;
23         }
24  
25 +       if (getenv("SELINUX_INIT") == NULL) {
26 +         putenv("SELINUX_INIT=YES");
27 +         if (selinux_init_load_policy(&enforce) == 0 ) {
28 +           execv(myname, argv);
29 +         } else {
30 +           if (enforce > 0) {
31 +             /* SELinux in enforcing mode but load_policy failed */
32 +             /* At this point, we probably can't open /dev/console, so log() won't work */
33 +                   initlog(L_VB,"Unable to load SELinux Policy. Machine is in enforcing mode. Halting now.");
34 +             exit(1);
35 +           }
36 +         }
37 +       }
38 +  
39         /* Start booting. */
40         argv0 = argv[0];
41         argv[1] = NULL;
42 Tylko w sysvinit-2.86/src: init.c.orig
43 diff -ur sysvinit-2.86.org/src/Makefile sysvinit-2.86/src/Makefile
44 --- sysvinit-2.86.org/src/Makefile      2005-12-24 23:21:59.000000000 +0100
45 +++ sysvinit-2.86/src/Makefile  2005-12-24 23:23:14.000000000 +0100
46 @@ -58,7 +58,7 @@
47  all:           $(BIN) $(SBIN) $(USRBIN)
48  
49  init:          init.o init_utmp.o
50 -               $(CC) $(LDFLAGS) $(STATIC) -o $@ init.o init_utmp.o
51 +               $(CC) $(LDFLAGS) $(STATIC) -o $@ init.o init_utmp.o -lsepol -lselinux
52  
53  halt:          halt.o ifdown.o hddown.o utmp.o reboot.h
54                 $(CC) $(LDFLAGS) -o $@ halt.o ifdown.o hddown.o utmp.o
55 @@ -79,7 +79,7 @@
56                 $(CC) $(LDFLAGS) -o $@ runlevel.o
57  
58  sulogin:       sulogin.o md5_broken.o md5_crypt_broken.o arc4random.o bcrypt.o blowfish.o
59 -               $(CC) $(LDFLAGS) $(STATIC) -o $@ $^ $(LCRYPT)
60 +               $(CC) $(LDFLAGS) $(STATIC) -o $@ $^ $(LCRYPT) -lselinux
61  
62  wall:          dowall.o wall.o
63                 $(CC) $(LDFLAGS) -o $@ dowall.o wall.o
64 Tylko w sysvinit-2.86.org/src: Makefile.orig
65 diff -ur sysvinit-2.86.org/src/sulogin.c sysvinit-2.86/src/sulogin.c
66 --- sysvinit-2.86.org/src/sulogin.c     2005-12-24 23:21:59.000000000 +0100
67 +++ sysvinit-2.86/src/sulogin.c 2005-12-24 23:23:33.000000000 +0100
68 @@ -30,6 +30,9 @@
69  #include "md5.h"
70  #include "blowfish.h"
71  
72 +#include <selinux/selinux.h>
73 +#include <selinux/get_context_list.h>
74 +
75  #define CHECK_DES      1
76  #define CHECK_MD5      1
77  #define CHECK_BLOWFISH 1
78 @@ -362,6 +365,19 @@
79         signal(SIGINT, SIG_DFL);
80         signal(SIGTSTP, SIG_DFL);
81         signal(SIGQUIT, SIG_DFL);
82 +       if (is_selinux_enabled > 0) {
83 +         security_context_t scon=NULL;
84 +         char *seuser=NULL;
85 +         char *level=NULL;
86 +         if (getseuserbyname("root", &seuser, &level) == 0)
87 +                 if (get_default_context_with_level(seuser, level, 0, &scon) > 0) {
88 +                         if (setexeccon(scon) != 0) 
89 +                                 fprintf(stderr, "setexeccon faile\n");
90 +                         freecon(scon);
91 +                 }
92 +               free(seuser);
93 +               free(level);
94 +       }
95         execl(sushell, shell, NULL);
96         perror(sushell);
97  
98 Tylko w sysvinit-2.86.org/src: sulogin.c.orig
This page took 0.110108 seconds and 3 git commands to generate.