diff options
author | Dan Williams <dcbw@redhat.com> | 2012-12-03 15:36:46 -0600 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2013-04-08 11:30:32 -0500 |
commit | a87b5a15df45d7974c942ffa6bc4a5453c269d4e (patch) | |
tree | 479f1f35a935717ce4125aee8faeee8e8596e6ad /libnm-glib/nm-object.c | |
parent | 661d09852d9b572932a6229a4092be6ee670cfab (diff) |
libnm-glib: use private connection before trying the system bus
Use the D-Bus connection helper whenever we need a connection to
NM, which by default tries to use a private connection instead of
the shared bus connection whenever the user is root. Doing this
by default will not change the behavior of libnm-glib, and allows
tools like nmcli and libnm-glib-using clients to work in minimal
environments (those without a bus daemon) by default.
Diffstat (limited to 'libnm-glib/nm-object.c')
-rw-r--r-- | libnm-glib/nm-object.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c index b133fee72..aa3ce799e 100644 --- a/libnm-glib/nm-object.c +++ b/libnm-glib/nm-object.c @@ -259,15 +259,13 @@ set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); - DBusGConnection *connection; switch (prop_id) { case PROP_CONNECTION: /* Construct only */ - connection = (DBusGConnection *) g_value_get_boxed (value); - if (!connection) - connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL); - priv->connection = dbus_g_connection_ref (connection); + priv->connection = g_value_dup_boxed (value); + if (!priv->connection) + priv->connection = _nm_dbus_new_connection (NULL); break; case PROP_PATH: /* Construct only */ @@ -1459,3 +1457,9 @@ _nm_object_new_proxy (NMObject *self, const char *path, const char *interface) return _nm_dbus_new_proxy_for_connection (priv->connection, path ? path : priv->path, interface); } +gboolean +_nm_object_is_connection_private (NMObject *self) +{ + return _nm_dbus_is_connection_private (NM_OBJECT_GET_PRIVATE (self)->connection); +} + |