[Initng-svn] r3801 - in initng/trunk: src

svn at initng.thinktux.net svn at initng.thinktux.net
Fri Apr 14 08:10:51 CEST 2006


Author: dragoran
Date: Fri Apr 14 08:10:48 2006
New Revision: 3801

Modified:
   initng/trunk/configure.ac
   initng/trunk/src/Makefile.am
   initng/trunk/src/main.c

Log:
Updated Selinux support

Modified: initng/trunk/configure.ac
==============================================================================
--- initng/trunk/configure.ac	(original)
+++ initng/trunk/configure.ac	Fri Apr 14 08:10:48 2006
@@ -109,6 +109,11 @@
     [selinux_support=$enableval],
     [selinux_support=no])
 
+AC_ARG_ENABLE(legacyselinux, 
+    AS_HELP_STRING(--enable-legacy-selinux,Initng will be build with legacy selinux support (for FC4) @<:@default=no@:>@),
+    [selinux_legacysupport=$enableval],
+    [selinux_legacysupport=no])
+
 AC_ARG_ENABLE(count-me,
     AS_HELP_STRING(--enable-count-me, report to user counter @<:@default=no@:>@),
     [count_me=$enableval],
@@ -301,6 +306,7 @@
 AM_CONDITIONAL(COUNT_ME, test "$count_me" = "yes")
 AM_CONDITIONAL(INSTALL_AS_INIT, test "$install_init" = "yes")
 AM_CONDITIONAL(ENABLE_SELINUX, test "$selinux_support" = "yes")
+AM_CONDITIONAL(ENABLE_LEGACYSELINUX, test "$selinux_legacysupport" = "yes")
 AM_CONDITIONAL(BUILD_ALSO, test "$with_also" = "yes")
 AM_CONDITIONAL(BUILD_BASH_LAUNCHER, test "$with_bash_launcher" = "yes")
 AM_CONDITIONAL(BUILD_CHDIR, test "$with_chdir" = "yes")
@@ -398,6 +404,7 @@
 echo
 echo Install as init........................ : $install_init
 echo Selinux support........................ : $selinux_support
+echo Legacy Selinux support................. : $selinux_legacysupport
 echo Docdir................................. : $docdir
 echo Build also plugin...................... : $with_also
 echo Build bash_launcher plugin............. : $with_bash_launcher

Modified: initng/trunk/src/Makefile.am
==============================================================================
--- initng/trunk/src/Makefile.am	(original)
+++ initng/trunk/src/Makefile.am	Fri Apr 14 08:10:48 2006
@@ -52,6 +52,10 @@
     AM_CFLAGS=-DSELINUX -lselinux -lsepol
 endif
 
+if ENABLE_LEGACYSELINUX
+    AM_CFLAGS=-DSELINUX -DOLSELINUX -lselinux -lsepol
+endif
+
 
 libinitng_la_SOURCES = \
 	initng.h \

Modified: initng/trunk/src/main.c
==============================================================================
--- initng/trunk/src/main.c	(original)
+++ initng/trunk/src/main.c	Fri Apr 14 08:10:48 2006
@@ -65,6 +65,8 @@
 
 #define TIMEOUT 60000
 #ifdef SELINUX
+/*older code no longer needed on FC5 and FCX (X>=5) */
+#ifdef OLDSELINUX
 /* Mount point for selinuxfs. */
 #define SELINUXMNT "/selinux/"
 int enforcing = -1;
@@ -264,7 +266,7 @@
 	return (ret);
 }
 #endif
-
+#endif
 
 static void setup_console(void)
 {
@@ -379,6 +381,7 @@
 	int loop_counter = 0;		/* counts how many times the main_loop has run */
 #endif
 #ifdef SELINUX
+#ifdef OLDSELINUX
 	if ((fopen("/selinux/enforce", "r")) != NULL)
 		goto BOOT;
 	int enforce = -1;
@@ -409,7 +412,23 @@
 
   BOOT:
 #endif
-
+#ifndef OLDSELINUX
+	int enforce = 0;
+   	if (getenv("SELINUX_INIT") == NULL) {
+	  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 */
+   	      fprintf(stderr,"Unable to load SELinux Policy. Machine is in enforcing mode. Halting now.");
+	      exit(1);
+	    }
+	  }
+	}
+#endif
+#endif
 	S_;
 
 	/* maby initng is launched only for getting the version */


More information about the Initng-svn mailing list