James Hunt has proposed merging lp:~jamesodhunt/upstart/disable-system-bus into 
lp:upstart.

Requested reviews:
  Upstart Reviewers (upstart-reviewers)

For more details, see:
https://code.launchpad.net/~jamesodhunt/upstart/disable-system-bus/+merge/186599

* init/control.c: Typo.
* init/main.c: Add '--no-dbus' command-line option.
  init/man/init.8: Added '--no-dbus' option.

This option has the effect of stopping Session Inits having access to 
system-level events for those systems which require such behaviour; in such 
environments, even if the upstart-event-bridge is running, no events will (can) 
be proxied from the system level.

A side-effect of booting with '--no-dbus' is that a non-priv user will be 
unable to query system jobs using initctl (since such users will not have 
access to the private socket). However, for those making use of '--no-dbus', 
such behaviour would be deemed a security advantage rather than a limitation.


-- 
https://code.launchpad.net/~jamesodhunt/upstart/disable-system-bus/+merge/186599
Your team Upstart Reviewers is requested to review the proposed merge of 
lp:~jamesodhunt/upstart/disable-system-bus into lp:upstart.
=== modified file 'ChangeLog'
--- ChangeLog	2013-09-13 04:44:55 +0000
+++ ChangeLog	2013-09-19 17:53:19 +0000
@@ -1,3 +1,9 @@
+2013-09-19  James Hunt  <[email protected]>
+
+	* init/control.c: Typo.
+	* init/main.c: Add '--no-dbus' command-line option.
+	  init/man/init.8: Added '--no-dbus' option.
+
 2013-09-12  Steve Langasek  <[email protected]>
 
 	* configure.ac:

=== modified file 'init/control.c'
--- init/control.c	2013-04-22 10:30:09 +0000
+++ init/control.c	2013-09-19 17:53:19 +0000
@@ -260,7 +260,7 @@
 
 	control_handle_bus_type ();
 
-	/* Connect to the D-Bus System Bus and hook everything up into
+	/* Connect to the appropriate D-Bus bus and hook everything up into
 	 * our own main loop automatically.
 	 */
 	conn = nih_dbus_bus (use_session_bus ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM,

=== modified file 'init/main.c'
--- init/main.c	2013-07-31 09:28:48 +0000
+++ init/main.c	2013-09-19 17:53:19 +0000
@@ -120,6 +120,14 @@
  **/
 static int disable_startup_event = FALSE;
 
+/**
+ * disable_dbus:
+ *
+ * If TRUE, do not connect to a D-Bus bus
+ * (only connect to the private socket).
+ **/
+static int disable_dbus = FALSE;
+
 extern int          no_inherit_env;
 extern int          user_mode;
 extern int          disable_sessions;
@@ -142,6 +150,9 @@
 	{ 0, "default-console", N_("default value for console stanza"),
 		NULL, "VALUE", NULL, console_type_setter },
 
+	{ 0, "no-dbus", N_("do not connect to a D-Bus bus"),
+		NULL, NULL, &disable_dbus, NULL },
+
 	{ 0, "no-inherit-env", N_("jobs will not inherit environment of init"),
 		NULL, NULL, &no_inherit_env ,NULL },
 
@@ -592,16 +603,21 @@
 	 * fail (since dbus-daemon probably isn't running yet) and will try again
 	 * later - don't let ENOMEM stop us though.
 	 */
-	while (control_bus_open () < 0) {
-		NihError *err;
-		int       number;
-
-		err = nih_error_get ();
-		number = err->number;
-		nih_free (err);
-
-		if (number != ENOMEM)
-			break;
+	if (disable_dbus) {
+		nih_info (_("Not connecting to %s bus"),
+				use_session_bus ? "session" : "system");
+	} else {
+		while (control_bus_open () < 0) {
+			NihError *err;
+			int       number;
+
+			err = nih_error_get ();
+			number = err->number;
+			nih_free (err);
+
+			if (number != ENOMEM)
+				break;
+		}
 	}
 
 #ifndef DEBUG
@@ -932,8 +948,12 @@
 usr1_handler (void      *data,
 	      NihSignal *signal)
 {
+	if (disable_dbus)
+		return;
+
 	if (! control_bus) {
-		nih_info (_("Reconnecting to system bus"));
+		nih_info (_("Reconnecting to %s bus"),
+				use_session_bus ? "session" : "system");
 
 		if (control_bus_open () < 0) {
 			NihError *err;

=== modified file 'init/man/init.8'
--- init/man/init.8	2013-04-02 10:19:07 +0000
+++ init/man/init.8	2013-09-19 17:53:19 +0000
@@ -84,6 +84,10 @@
 .BR console "."
 .\"
 .TP
+.B \-\-no\-dbus
+Do not connect to a D-Bus bus.
+.\"
+.TP
 .B \-\-no\-inherit\-env
 Stop jobs from inheriting the initial environment. Only meaningful when
 running in user mode.

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to