From e3fc25731ef96c4e487d0e44ffc0bb44e4db7686 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 17 Apr 2014 16:58:18 -0400 Subject: [PATCH] dbus-manager: don't try to create private bus in test programs When running test programs, don't try to create a private bus, since it will fail if the user isn't root or if NetworkManager is currently running, and it isn't what we want anyway. --- src/nm-dbus-manager.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/nm-dbus-manager.c b/src/nm-dbus-manager.c index 2702faaba0..f9269b6157 100644 --- a/src/nm-dbus-manager.c +++ b/src/nm-dbus-manager.c @@ -466,16 +466,16 @@ private_connection_disconnected (NMDBusManager *self, DBusGConnection *connectio g_signal_emit (G_OBJECT (self), signals[NAME_OWNER_CHANGED], 0, owner, owner, NULL); } -#endif /* HAVE_DBUS_GLIB_100 */ static void -nm_dbus_manager_init (NMDBusManager *self) +private_server_setup (NMDBusManager *self) { NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (self); - priv->exported = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free); + /* Skip this step if this is just a test program */ + if (g_test_initialized ()) + return; -#if HAVE_DBUS_GLIB_100 /* Set up our main private DBus socket */ if (mkdir (NMRUNDIR, 0700) == -1) { if (errno != EEXIST) @@ -494,6 +494,18 @@ nm_dbus_manager_init (NMDBusManager *self) (GCallback) private_connection_disconnected, NULL); } +} +#endif /* HAVE_DBUS_GLIB_100 */ + +static void +nm_dbus_manager_init (NMDBusManager *self) +{ + NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (self); + + priv->exported = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free); + +#if HAVE_DBUS_GLIB_100 + private_server_setup (self); #endif }