object,
NULL);
- if (_nm_object_is_connection_private (NM_OBJECT (object)))
- priv->manager_running = TRUE;
- else {
- priv->bus_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
- g_assert (priv->bus_proxy);
-
- dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->bus_proxy,
- "NameOwnerChanged",
- G_CALLBACK (proxy_name_owner_changed),
- object, NULL);
- }
+ priv->bus_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+ g_assert (priv->bus_proxy);
+
+ dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (priv->bus_proxy,
+ "NameOwnerChanged",
+ G_CALLBACK (proxy_name_owner_changed),
+ object, NULL);
g_signal_connect (object, "notify::" NM_CLIENT_WIRELESS_ENABLED,
G_CALLBACK (wireless_enabled_cb), NULL);
if (!nm_client_parent_initable_iface->init (initable, cancellable, error))
return FALSE;
- if (!_nm_object_is_connection_private (NM_OBJECT (client))) {
- if (!dbus_g_proxy_call (priv->bus_proxy,
- "NameHasOwner", error,
- G_TYPE_STRING, NM_DBUS_SERVICE,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &priv->manager_running,
- G_TYPE_INVALID))
- return FALSE;
- }
+ if (!dbus_g_proxy_call (priv->bus_proxy,
+ "NameHasOwner", error,
+ G_TYPE_STRING, NM_DBUS_SERVICE,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, &priv->manager_running,
+ G_TYPE_INVALID))
+ return FALSE;
if (priv->manager_running && !get_permissions_sync (client, error))
return FALSE;
user_data, init_async);
g_simple_async_result_set_op_res_gboolean (init_data->result, TRUE);
- if (_nm_object_is_connection_private (NM_OBJECT (init_data->client)))
- finish_init (init_data);
- else {
- /* Check if NM is running */
- dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner",
- init_async_got_manager_running,
- init_data, NULL,
- G_TYPE_STRING, NM_DBUS_SERVICE,
- G_TYPE_INVALID);
- }
+ /* Check if NM is running */
+ dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner",
+ init_async_got_manager_running,
+ init_data, NULL,
+ G_TYPE_STRING, NM_DBUS_SERVICE,
+ G_TYPE_INVALID);
}
static gboolean
DBusGConnection *_nm_dbus_new_connection (GError **error);
-gboolean _nm_dbus_is_connection_private (DBusGConnection *connection);
-
DBusGProxy * _nm_dbus_new_proxy_for_connection (DBusGConnection *connection,
const char *path,
const char *interface);
#include "nm-dbus-helpers-private.h"
#include "NetworkManager.h"
-static dbus_int32_t priv_slot = -1;
-
-static gboolean
-_ensure_dbus_data_slot (void)
-{
- static gsize init_value = 0;
- gboolean success = TRUE;
-
- if (g_once_init_enter (&init_value)) {
- success = dbus_connection_allocate_data_slot (&priv_slot);
- g_once_init_leave (&init_value, 1);
- }
- return success;
-}
-
DBusGConnection *
_nm_dbus_new_connection (GError **error)
{
DBusGConnection *connection = NULL;
- if (!_ensure_dbus_data_slot ()) {
- g_set_error (error, DBUS_GERROR, DBUS_GERROR_FAILED, "failed to allocated data slot");
- return NULL;
- }
-
-#if HAVE_DBUS_GLIB_100
- /* If running as root try the private bus first */
- if (0 == geteuid ()) {
- connection = dbus_g_connection_open ("unix:path=" NMRUNDIR "/private", error);
- if (connection) {
- DBusConnection *dbus_connection = dbus_g_connection_get_connection (connection);
-
- /* Mark this connection as private */
- dbus_connection_set_data (dbus_connection, priv_slot, GUINT_TO_POINTER (TRUE), NULL);
- dbus_connection_set_exit_on_disconnect (dbus_connection, FALSE);
- return connection;
- }
- /* Fall back to a bus if for some reason private socket isn't available */
- g_clear_error (error);
- }
-#endif
-
if (connection == NULL)
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, error);
return connection;
}
-gboolean
-_nm_dbus_is_connection_private (DBusGConnection *connection)
-{
- if (!_ensure_dbus_data_slot ())
- return FALSE;
- return !!dbus_connection_get_data (dbus_g_connection_get_connection (connection), priv_slot);
-}
-
DBusGProxy *
_nm_dbus_new_proxy_for_connection (DBusGConnection *connection,
const char *path,
const char *interface)
{
- /* Private connections can't use dbus_g_proxy_new_for_name() or
- * dbus_g_proxy_new_for_name_owner() because peer-to-peer connections don't
- * have either a bus daemon or name owners, both of which those functions
- * require.
- */
- if (_nm_dbus_is_connection_private (connection))
- return dbus_g_proxy_new_for_peer (connection, path, interface);
-
return dbus_g_proxy_new_for_name (connection, NM_DBUS_SERVICE, path, interface);
}
const char *path,
const char *interface);
-gboolean _nm_object_is_connection_private (NMObject *self);
-
void _nm_object_register_properties (NMObject *object,
DBusGProxy *proxy,
const NMPropertiesInfo *info);
priv->properties_proxy = _nm_object_new_proxy (self, NULL, DBUS_INTERFACE_PROPERTIES);
- if (_nm_object_is_connection_private (self))
- priv->nm_running = TRUE;
- else {
- priv->bus_proxy = dbus_g_proxy_new_for_name (priv->connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
- g_assert (priv->bus_proxy);
-
- dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->bus_proxy,
- "NameOwnerChanged",
- G_CALLBACK (proxy_name_owner_changed),
- object, NULL);
- }
+ priv->bus_proxy = dbus_g_proxy_new_for_name (priv->connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+ g_assert (priv->bus_proxy);
+
+ dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (priv->bus_proxy,
+ "NameOwnerChanged",
+ G_CALLBACK (proxy_name_owner_changed),
+ object, NULL);
}
static gboolean
simple = g_simple_async_result_new (G_OBJECT (initable), callback, user_data, init_async);
- if (_nm_object_is_connection_private (NM_OBJECT (initable)))
- _nm_object_reload_properties_async (NM_OBJECT (initable), init_async_got_properties, simple);
- else {
- /* Check if NM is running */
- dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner",
- init_async_got_manager_running,
- simple, NULL,
- G_TYPE_STRING, NM_DBUS_SERVICE,
- G_TYPE_INVALID);
- }
+ /* Check if NM is running */
+ dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner",
+ init_async_got_manager_running,
+ simple, NULL,
+ G_TYPE_STRING, NM_DBUS_SERVICE,
+ G_TYPE_INVALID);
}
static gboolean
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);
-}
typedef struct {
DBusGConnection *bus;
- gboolean private_bus;
gboolean inited;
DBusGProxy *proxy;
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
- if (priv->private_bus == FALSE) {
- /* D-Bus proxy for clearing connections on NameOwnerChanged */
- priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->bus,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
- g_assert (priv->dbus_proxy);
-
- dbus_g_object_register_marshaller (g_cclosure_marshal_generic,
- G_TYPE_NONE,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (priv->dbus_proxy, "NameOwnerChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->dbus_proxy,
- "NameOwnerChanged",
- G_CALLBACK (name_owner_changed),
- object, NULL);
- }
+ /* D-Bus proxy for clearing connections on NameOwnerChanged */
+ priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->bus,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+ g_assert (priv->dbus_proxy);
+
+ dbus_g_object_register_marshaller (g_cclosure_marshal_generic,
+ G_TYPE_NONE,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (priv->dbus_proxy, "NameOwnerChanged",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (priv->dbus_proxy,
+ "NameOwnerChanged",
+ G_CALLBACK (name_owner_changed),
+ object, NULL);
priv->proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
NM_DBUS_PATH_SETTINGS,
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
GHashTable *props;
- if (priv->private_bus == FALSE) {
- if (!dbus_g_proxy_call (priv->dbus_proxy, "NameHasOwner", error,
- G_TYPE_STRING, NM_DBUS_SERVICE,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &priv->service_running,
- G_TYPE_INVALID)) {
- priv->service_running = FALSE;
- return FALSE;
- }
+ if (!dbus_g_proxy_call (priv->dbus_proxy, "NameHasOwner", error,
+ G_TYPE_STRING, NM_DBUS_SERVICE,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, &priv->service_running,
+ G_TYPE_INVALID)) {
+ priv->service_running = FALSE;
+ return FALSE;
+ }
- /* If NM isn't running we'll grab properties from name_owner_changed()
- * when it starts.
- */
- if (!priv->service_running)
- return TRUE;
- } else
- priv->service_running = TRUE;
+ /* If NM isn't running we'll grab properties from name_owner_changed()
+ * when it starts.
+ */
+ if (!priv->service_running)
+ return TRUE;
priv->listcon_call = dbus_g_proxy_begin_call (priv->proxy, "ListConnections",
fetch_connections_done, NM_REMOTE_SETTINGS (initable), NULL,
init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback,
user_data, init_async);
- if (priv->private_bus) {
- priv->service_running = TRUE;
- init_get_properties (init_data);
- } else {
- /* Check if NM is running */
- dbus_g_proxy_begin_call (priv->dbus_proxy, "NameHasOwner",
- init_async_got_manager_running,
- init_data, NULL,
- G_TYPE_STRING, NM_DBUS_SERVICE,
- G_TYPE_INVALID);
- }
+ /* Check if NM is running */
+ dbus_g_proxy_begin_call (priv->dbus_proxy, "NameHasOwner",
+ init_async_got_manager_running,
+ init_data, NULL,
+ G_TYPE_STRING, NM_DBUS_SERVICE,
+ G_TYPE_INVALID);
}
static gboolean
case PROP_BUS:
/* Construct only */
priv->bus = g_value_dup_boxed (value);
- if (!priv->bus) {
+ if (!priv->bus)
priv->bus = _nm_dbus_new_connection (NULL);
- priv->private_bus = _nm_dbus_is_connection_private (priv->bus);
- }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
NMSecretAgentCapabilities capabilities;
DBusGConnection *bus;
- gboolean private_bus;
DBusGProxy *dbus_proxy;
DBusGProxy *manager_proxy;
DBusGProxyCall *reg_call;
g_return_val_if_fail (context != NULL, FALSE);
- /* Private bus connection is always to NetworkManager, which is always
- * UID 0.
- */
- if (priv->private_bus)
- return TRUE;
-
/* Verify the sender's UID is 0, and that the sender is the same as
* NetworkManager's bus name owner.
*/
g_return_val_if_fail (class->save_secrets != NULL, FALSE);
g_return_val_if_fail (class->delete_secrets != NULL, FALSE);
- if (!priv->nm_owner && !priv->private_bus)
+ if (!priv->nm_owner)
return FALSE;
priv->suppress_auto = FALSE;
g_return_val_if_fail (priv->bus != NULL, FALSE);
g_return_val_if_fail (priv->manager_proxy != NULL, FALSE);
- if (!priv->nm_owner && !priv->private_bus)
+ if (!priv->nm_owner)
return FALSE;
dbus_g_proxy_call_no_reply (priv->manager_proxy, "Unregister", G_TYPE_INVALID);
g_error_free (error);
return;
}
- priv->private_bus = _nm_dbus_is_connection_private (priv->bus);
-
- if (priv->private_bus == FALSE) {
- priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->bus,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
- g_assert (priv->dbus_proxy);
-
- dbus_g_object_register_marshaller (g_cclosure_marshal_generic,
- G_TYPE_NONE,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (priv->dbus_proxy, "NameOwnerChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->dbus_proxy,
- "NameOwnerChanged",
- G_CALLBACK (name_owner_changed),
- self, NULL);
-
- get_nm_owner (self);
- }
+
+ priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->bus,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+ g_assert (priv->dbus_proxy);
+
+ dbus_g_object_register_marshaller (g_cclosure_marshal_generic,
+ G_TYPE_NONE,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (priv->dbus_proxy, "NameOwnerChanged",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (priv->dbus_proxy,
+ "NameOwnerChanged",
+ G_CALLBACK (name_owner_changed),
+ self, NULL);
+
+ get_nm_owner (self);
priv->manager_proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
NM_DBUS_PATH_AGENT_MANAGER,
return;
}
- if (priv->nm_owner || priv->private_bus)
+ if (priv->nm_owner)
priv->auto_register_id = g_idle_add (auto_register_cb, self);
}