dbus/bus test-main.c, 1.19, 1.20 selinux.h, 1.4, 1.5 selinux.c, 1.7, 1.8 main.c, 1.27, 1.28

Colin Walters walters at freedesktop.org
Tue Nov 2 12:27:50 PST 2004


Update of /cvs/dbus/dbus/bus
In directory gabe:/tmp/cvs-serv22368/bus

Modified Files:
	test-main.c selinux.h selinux.c main.c 
Log Message:
2004-11-02  Colin Walters  <walters at verbum.org>

	* bus/selinux.c (bus_selinux_init): Split into two functions,
	bus_selinux_pre_init and bus_selinux_post_init.
	(bus_selinux_pre_init): Just determine whether SELinux is
	enabled.
	(bus_selinux_post_init): Do everything else.

	* bus/main.c (main): Call bus_selinux_pre_init before parsing
	config file, and bus_selinux_post_init after.  This ensures that
	we don't lose the policyreload notification thread that
	bus_selinux_init created before forking previously.
	
	* bus/test-main.c (test_pre_hook): Update for split.


Index: test-main.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/test-main.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- test-main.c	23 Aug 2004 16:09:53 -0000	1.19
+++ test-main.c	2 Nov 2004 20:27:47 -0000	1.20
@@ -56,7 +56,9 @@
 test_pre_hook (void)
 {
   
-  if (_dbus_getenv ("DBUS_TEST_SELINUX") && !bus_selinux_init ())
+  if (_dbus_getenv ("DBUS_TEST_SELINUX")
+      && !bus_selinux_pre_init ()
+      && !bus_selinux_full_init ())
     die ("could not init selinux support");
 }
 

Index: selinux.h
===================================================================
RCS file: /cvs/dbus/dbus/bus/selinux.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- selinux.h	18 Oct 2004 04:04:12 -0000	1.4
+++ selinux.h	2 Nov 2004 20:27:47 -0000	1.5
@@ -27,7 +27,8 @@
 #include <dbus/dbus-connection.h>
 #include "services.h"
 
-dbus_bool_t bus_selinux_init     (void);
+dbus_bool_t bus_selinux_pre_init (void);
+dbus_bool_t bus_selinux_full_init(void);
 void        bus_selinux_shutdown (void);
 
 dbus_bool_t bus_selinux_enabled  (void);

Index: selinux.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/selinux.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- selinux.c	18 Oct 2004 13:06:41 -0000	1.7
+++ selinux.c	2 Nov 2004 20:27:47 -0000	1.8
@@ -205,11 +205,10 @@
 }
 
 /**
- * Initialize the user space access vector cache (AVC) for D-BUS and set up
- * logging callbacks.
+ * Do early initialization; determine whether SELinux is enabled.
  */
 dbus_bool_t
-bus_selinux_init (void)
+bus_selinux_pre_init (void)
 {
 #ifdef HAVE_SELINUX
   int r;
@@ -227,7 +226,25 @@
     }
 
   selinux_enabled = r != 0;
+  return TRUE;
+#else
+  return TRUE;
+#endif
+}
 
+/**
+ * Initialize the user space access vector cache (AVC) for D-BUS and set up
+ * logging callbacks.
+ */
+dbus_bool_t
+bus_selinux_full_init (void)
+{
+#ifdef HAVE_SELINUX
+  int r;
+  char *bus_context;
+
+  _dbus_assert (bus_sid == SECSID_WILD);
+  
   if (!selinux_enabled)
     {
       _dbus_verbose ("SELinux not enabled in this kernel.\n");

Index: main.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/main.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- main.c	12 Sep 2004 10:23:42 -0000	1.27
+++ main.c	2 Nov 2004 20:27:47 -0000	1.28
@@ -377,9 +377,9 @@
     }
   _dbus_string_free (&pid_fd);
 
-  if (!bus_selinux_init ())
+  if (!bus_selinux_pre_init ())
     {
-      _dbus_warn ("SELinux initialization failed\n");
+      _dbus_warn ("SELinux pre-initialization failed\n");
       exit (1);
     }
 
@@ -396,6 +396,12 @@
       exit (1);
     }
 
+  if (!bus_selinux_full_init ())
+    {
+      _dbus_warn ("SELinux initialization failed\n");
+      exit (1);
+    }
+
   setup_reload_pipe (bus_context_get_loop (context));
  
   _dbus_set_signal_handler (SIGHUP, signal_handler);



More information about the dbus-commit mailing list