diff options
author | Dan Winship <danw@gnome.org> | 2014-09-05 12:55:18 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-09-09 12:10:13 -0400 |
commit | b732380d1eb86d4278578559b0ec00990202e3fc (patch) | |
tree | 29b9cdfb594c2f712bc63a4dbcc05b1775b2b49f /libnm/nm-dbus-helpers.c | |
parent | a874e0beac9832b7c9df8360b16dba69122765a5 (diff) | |
download | NetworkManager-b732380d1eb86d4278578559b0ec00990202e3fc.tar.gz |
libnm: drop NMObject:dbus-connection
The only plausible use case for the NMObject:dbus-connection property
is for using the session bus in test programs. So just drop it and use
an environment variable to decide which bus to use instead.
Diffstat (limited to 'libnm/nm-dbus-helpers.c')
-rw-r--r-- | libnm/nm-dbus-helpers.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libnm/nm-dbus-helpers.c b/libnm/nm-dbus-helpers.c index 64b708616c..464facef8b 100644 --- a/libnm/nm-dbus-helpers.c +++ b/libnm/nm-dbus-helpers.c @@ -27,15 +27,20 @@ #include "nm-dbus-interface.h" static dbus_int32_t priv_slot = -1; +static DBusBusType nm_bus = DBUS_BUS_SYSTEM; static void -_ensure_dbus_data_slot (void) +_ensure_nm_dbus_helpers_inited (void) { static gsize init_value = 0; if (g_once_init_enter (&init_value)) { dbus_connection_allocate_data_slot (&priv_slot); g_assert (priv_slot != -1); + + if (g_getenv ("LIBNM_USE_SESSION_BUS")) + nm_bus = DBUS_BUS_SESSION; + g_once_init_leave (&init_value, 1); } } @@ -45,11 +50,11 @@ _nm_dbus_new_connection (GError **error) { DBusGConnection *connection = NULL; - _ensure_dbus_data_slot (); + _ensure_nm_dbus_helpers_inited (); #if HAVE_DBUS_GLIB_100 /* If running as root try the private bus first */ - if (0 == geteuid ()) { + if (0 == geteuid () && nm_bus == DBUS_BUS_SYSTEM) { connection = dbus_g_connection_open ("unix:path=" NMRUNDIR "/private", error); if (connection) { DBusConnection *dbus_connection = dbus_g_connection_get_connection (connection); @@ -65,7 +70,7 @@ _nm_dbus_new_connection (GError **error) #endif if (connection == NULL) - connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, error); + connection = dbus_g_bus_get (nm_bus, error); return connection; } |