commit 8627880e07c8345f69ed639325280c7f62a8f894
Author: Dan Williams <dcbw@redhat.com>
Date:   Wed Dec 9 17:42:36 2009 -0800

    editor: prevent any registration of objects on the system bus
    
    D-Bus access-control is name-based; so requests for a specific name
    are allowed/denied based on the rules in /etc/dbus-1/system.d.  But
    apparently apps still get a non-named service on the bus, and if we
    register *any* object even though we don't have a named service,
    dbus and dbus-glib will happily proxy signals.  Since the connection
    editor shouldn't ever expose anything having to do with connections
    on any bus, make sure that's the case.

Index: network-manager-applet-0.7.1/src/applet.c
===================================================================
--- network-manager-applet-0.7.1.orig/src/applet.c
+++ network-manager-applet-0.7.1/src/applet.c
@@ -2527,15 +2527,11 @@ constructor (GType type,
 
 	applet->dbus_settings = (NMDBusSettings *) nm_dbus_settings_system_new (applet_dbus_manager_get_connection (dbus_mgr));
 
-	applet->gconf_settings = nma_gconf_settings_new ();
+	applet->gconf_settings = nma_gconf_settings_new (applet_dbus_manager_get_connection (dbus_mgr));
 	g_signal_connect (applet->gconf_settings, "new-secrets-requested",
 	                  G_CALLBACK (applet_settings_new_secrets_requested_cb),
 	                  applet);
 
-	dbus_g_connection_register_g_object (applet_dbus_manager_get_connection (dbus_mgr),
-	                                     NM_DBUS_PATH_SETTINGS,
-	                                     G_OBJECT (applet->gconf_settings));
-
 	/* Start our DBus service */
 	if (!applet_dbus_manager_start_service (dbus_mgr)) {
 			g_object_unref (applet);
Index: network-manager-applet-0.7.1/src/connection-editor/nm-connection-list.c
===================================================================
--- network-manager-applet-0.7.1.orig/src/connection-editor/nm-connection-list.c
+++ network-manager-applet-0.7.1/src/connection-editor/nm-connection-list.c
@@ -1944,7 +1944,7 @@ nm_connection_list_new (const char *def_
 				   G_CALLBACK (connection_added),
 				   list);
 
-	list->gconf_settings = nma_gconf_settings_new ();
+	list->gconf_settings = nma_gconf_settings_new (NULL);
 	g_signal_connect (list->gconf_settings, "new-connection",
 				   G_CALLBACK (connection_added),
 				   list);
Index: network-manager-applet-0.7.1/src/gconf-helpers/nma-gconf-connection.c
===================================================================
--- network-manager-applet-0.7.1.orig/src/gconf-helpers/nma-gconf-connection.c
+++ network-manager-applet-0.7.1/src/gconf-helpers/nma-gconf-connection.c
@@ -523,7 +523,6 @@ constructor (GType type,
 	GObject *object;
 	NMAGConfConnectionPrivate *priv;
 	NMConnection *connection;
-	DBusGConnection *bus;
 	GError *error = NULL;
 
 	object = G_OBJECT_CLASS (nma_gconf_connection_parent_class)->constructor (type, n_construct_params, construct_params);
@@ -566,18 +565,6 @@ constructor (GType type,
 
 	fill_vpn_user_name (connection);
 
-	bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-	if (!bus) {
-		nm_warning ("Could not get the system bus: %s", error->message);
-		g_error_free (error);
-		goto err;
-	}
-
-	nm_exported_connection_register_object (NM_EXPORTED_CONNECTION (object),
-	                                        NM_CONNECTION_SCOPE_USER,
-	                                        bus);
-	dbus_g_connection_unref (bus);
-
 	return object;
 
  err:
Index: network-manager-applet-0.7.1/src/gconf-helpers/nma-gconf-settings.c
===================================================================
--- network-manager-applet-0.7.1.orig/src/gconf-helpers/nma-gconf-settings.c
+++ network-manager-applet-0.7.1/src/gconf-helpers/nma-gconf-settings.c
@@ -24,6 +24,7 @@
 #include "gconf-helpers.h"
 #include "nma-marshal.h"
 #include "nm-utils.h"
+#include <NetworkManager.h>
 
 G_DEFINE_TYPE (NMAGConfSettings, nma_gconf_settings, NM_TYPE_SETTINGS)
 
@@ -36,6 +37,8 @@ typedef struct {
 	guint read_connections_id;
 	GHashTable *pending_changes;
 
+	DBusGConnection *bus;
+
 	gboolean disposed;
 } NMAGConfSettingsPrivate;
 
@@ -49,9 +52,22 @@ static guint signals[LAST_SIGNAL] = { 0
 
 
 NMAGConfSettings *
-nma_gconf_settings_new (void)
+nma_gconf_settings_new (DBusGConnection *bus)
 {
-	return (NMAGConfSettings *) g_object_new (NMA_TYPE_GCONF_SETTINGS, NULL);
+	NMAGConfSettings *self;
+	NMAGConfSettingsPrivate *priv;
+
+	self = (NMAGConfSettings *) g_object_new (NMA_TYPE_GCONF_SETTINGS, NULL);
+	if (!self)
+		return NULL;
+
+	priv = NMA_GCONF_SETTINGS_GET_PRIVATE (self);
+	if (bus) {
+		priv->bus = dbus_g_connection_ref (bus);
+		dbus_g_connection_register_g_object (bus, NM_DBUS_PATH_SETTINGS, G_OBJECT (self));
+	}
+
+	return self;
 }
 
 static void
@@ -91,16 +107,23 @@ add_connection_real (NMAGConfSettings *s
 {
 	NMAGConfSettingsPrivate *priv = NMA_GCONF_SETTINGS_GET_PRIVATE (self);
 
-	if (connection) {
-		priv->connections = g_slist_prepend (priv->connections, connection);
-		g_signal_connect (connection, "new-secrets-requested",
-					   G_CALLBACK (connection_new_secrets_requested_cb),
-					   self);
-
-		g_signal_connect (connection, "removed", G_CALLBACK (connection_removed), self);
-		nm_settings_signal_new_connection (NM_SETTINGS (self),
-									NM_EXPORTED_CONNECTION (connection));
+	g_return_if_fail (connection != NULL);
+
+	priv->connections = g_slist_prepend (priv->connections, connection);
+	g_signal_connect (connection, "new-secrets-requested",
+				   G_CALLBACK (connection_new_secrets_requested_cb),
+				   self);
+
+	g_signal_connect (connection, "removed", G_CALLBACK (connection_removed), self);
+
+	/* Export the connection over dbus if requested */
+	if (priv->bus) {
+		nm_exported_connection_register_object (NM_EXPORTED_CONNECTION (connection),
+		                                        NM_CONNECTION_SCOPE_USER,
+		                                        priv->bus);
 	}
+
+	nm_settings_signal_new_connection (NM_SETTINGS (self), NM_EXPORTED_CONNECTION (connection));
 }
 
 NMAGConfConnection *
@@ -231,8 +254,11 @@ read_connections (NMAGConfSettings *sett
 
 	for (iter = dir_list; iter; iter = iter->next) {
 		char *dir = (char *) iter->data;
+		NMAGConfConnection *connection;
 
-		add_connection_real (settings, nma_gconf_connection_new (priv->client, dir));
+		connection = nma_gconf_connection_new (priv->client, dir);
+		if (connection)
+			add_connection_real (settings, connection);
 		g_free (dir);
 	}
 
@@ -289,7 +315,8 @@ connection_changes_done (gpointer data)
 	if (!connection) {
 		/* New connection */
 		connection = nma_gconf_connection_new (priv->client, info->path);
-		add_connection_real (info->settings, connection);
+		if (connection)
+			add_connection_real (info->settings, connection);
 	} else {
 		if (gconf_client_dir_exists (priv->client, info->path, NULL)) {
 			/* Updated connection */
@@ -405,6 +432,9 @@ dispose (GObject *object)
 
 	priv->disposed = TRUE;
 
+	if (priv->bus)
+		dbus_g_connection_unref (priv->bus);
+
 	g_hash_table_destroy (priv->pending_changes);
 
 	if (priv->read_connections_id) {
Index: network-manager-applet-0.7.1/src/gconf-helpers/nma-gconf-settings.h
===================================================================
--- network-manager-applet-0.7.1.orig/src/gconf-helpers/nma-gconf-settings.h
+++ network-manager-applet-0.7.1/src/gconf-helpers/nma-gconf-settings.h
@@ -53,7 +53,7 @@ typedef struct {
 
 GType nma_gconf_settings_get_type (void);
 
-NMAGConfSettings *nma_gconf_settings_new (void);
+NMAGConfSettings *nma_gconf_settings_new (DBusGConnection *bus);
 
 NMAGConfConnection *nma_gconf_settings_add_connection (NMAGConfSettings *self,
 											NMConnection *connection);
