libnm-glib: drop private bus support
Anything that actually *needs* private bus support will be built against libnm these days anyway.
This commit is contained in:
@@ -1798,9 +1798,6 @@ constructed (GObject *object)
|
|||||||
object,
|
object,
|
||||||
NULL);
|
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)),
|
priv->bus_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
|
||||||
DBUS_SERVICE_DBUS,
|
DBUS_SERVICE_DBUS,
|
||||||
DBUS_PATH_DBUS,
|
DBUS_PATH_DBUS,
|
||||||
@@ -1814,7 +1811,6 @@ constructed (GObject *object)
|
|||||||
"NameOwnerChanged",
|
"NameOwnerChanged",
|
||||||
G_CALLBACK (proxy_name_owner_changed),
|
G_CALLBACK (proxy_name_owner_changed),
|
||||||
object, NULL);
|
object, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
g_signal_connect (object, "notify::" NM_CLIENT_WIRELESS_ENABLED,
|
g_signal_connect (object, "notify::" NM_CLIENT_WIRELESS_ENABLED,
|
||||||
G_CALLBACK (wireless_enabled_cb), NULL);
|
G_CALLBACK (wireless_enabled_cb), NULL);
|
||||||
@@ -1835,7 +1831,6 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
|
|||||||
if (!nm_client_parent_initable_iface->init (initable, cancellable, error))
|
if (!nm_client_parent_initable_iface->init (initable, cancellable, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!_nm_object_is_connection_private (NM_OBJECT (client))) {
|
|
||||||
if (!dbus_g_proxy_call (priv->bus_proxy,
|
if (!dbus_g_proxy_call (priv->bus_proxy,
|
||||||
"NameHasOwner", error,
|
"NameHasOwner", error,
|
||||||
G_TYPE_STRING, NM_DBUS_SERVICE,
|
G_TYPE_STRING, NM_DBUS_SERVICE,
|
||||||
@@ -1843,7 +1838,6 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
|
|||||||
G_TYPE_BOOLEAN, &priv->manager_running,
|
G_TYPE_BOOLEAN, &priv->manager_running,
|
||||||
G_TYPE_INVALID))
|
G_TYPE_INVALID))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->manager_running && !get_permissions_sync (client, error))
|
if (priv->manager_running && !get_permissions_sync (client, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -1953,16 +1947,12 @@ init_async (GAsyncInitable *initable, int io_priority,
|
|||||||
user_data, init_async);
|
user_data, init_async);
|
||||||
g_simple_async_result_set_op_res_gboolean (init_data->result, TRUE);
|
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 */
|
/* Check if NM is running */
|
||||||
dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner",
|
dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner",
|
||||||
init_async_got_manager_running,
|
init_async_got_manager_running,
|
||||||
init_data, NULL,
|
init_data, NULL,
|
||||||
G_TYPE_STRING, NM_DBUS_SERVICE,
|
G_TYPE_STRING, NM_DBUS_SERVICE,
|
||||||
G_TYPE_INVALID);
|
G_TYPE_INVALID);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@@ -28,8 +28,6 @@
|
|||||||
|
|
||||||
DBusGConnection *_nm_dbus_new_connection (GError **error);
|
DBusGConnection *_nm_dbus_new_connection (GError **error);
|
||||||
|
|
||||||
gboolean _nm_dbus_is_connection_private (DBusGConnection *connection);
|
|
||||||
|
|
||||||
DBusGProxy * _nm_dbus_new_proxy_for_connection (DBusGConnection *connection,
|
DBusGProxy * _nm_dbus_new_proxy_for_connection (DBusGConnection *connection,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *interface);
|
const char *interface);
|
||||||
|
@@ -27,74 +27,21 @@
|
|||||||
#include "nm-dbus-helpers-private.h"
|
#include "nm-dbus-helpers-private.h"
|
||||||
#include "NetworkManager.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 *
|
DBusGConnection *
|
||||||
_nm_dbus_new_connection (GError **error)
|
_nm_dbus_new_connection (GError **error)
|
||||||
{
|
{
|
||||||
DBusGConnection *connection = NULL;
|
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)
|
if (connection == NULL)
|
||||||
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, error);
|
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, error);
|
||||||
|
|
||||||
return connection;
|
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 *
|
DBusGProxy *
|
||||||
_nm_dbus_new_proxy_for_connection (DBusGConnection *connection,
|
_nm_dbus_new_proxy_for_connection (DBusGConnection *connection,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *interface)
|
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);
|
return dbus_g_proxy_new_for_name (connection, NM_DBUS_SERVICE, path, interface);
|
||||||
}
|
}
|
||||||
|
@@ -42,8 +42,6 @@ DBusGProxy *_nm_object_new_proxy (NMObject *self,
|
|||||||
const char *path,
|
const char *path,
|
||||||
const char *interface);
|
const char *interface);
|
||||||
|
|
||||||
gboolean _nm_object_is_connection_private (NMObject *self);
|
|
||||||
|
|
||||||
void _nm_object_register_properties (NMObject *object,
|
void _nm_object_register_properties (NMObject *object,
|
||||||
DBusGProxy *proxy,
|
DBusGProxy *proxy,
|
||||||
const NMPropertiesInfo *info);
|
const NMPropertiesInfo *info);
|
||||||
|
@@ -174,9 +174,6 @@ constructed (GObject *object)
|
|||||||
|
|
||||||
priv->properties_proxy = _nm_object_new_proxy (self, NULL, DBUS_INTERFACE_PROPERTIES);
|
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,
|
priv->bus_proxy = dbus_g_proxy_new_for_name (priv->connection,
|
||||||
DBUS_SERVICE_DBUS,
|
DBUS_SERVICE_DBUS,
|
||||||
DBUS_PATH_DBUS,
|
DBUS_PATH_DBUS,
|
||||||
@@ -190,7 +187,6 @@ constructed (GObject *object)
|
|||||||
"NameOwnerChanged",
|
"NameOwnerChanged",
|
||||||
G_CALLBACK (proxy_name_owner_changed),
|
G_CALLBACK (proxy_name_owner_changed),
|
||||||
object, NULL);
|
object, NULL);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -272,16 +268,12 @@ init_async (GAsyncInitable *initable, int io_priority,
|
|||||||
|
|
||||||
simple = g_simple_async_result_new (G_OBJECT (initable), callback, user_data, init_async);
|
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 */
|
/* Check if NM is running */
|
||||||
dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner",
|
dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner",
|
||||||
init_async_got_manager_running,
|
init_async_got_manager_running,
|
||||||
simple, NULL,
|
simple, NULL,
|
||||||
G_TYPE_STRING, NM_DBUS_SERVICE,
|
G_TYPE_STRING, NM_DBUS_SERVICE,
|
||||||
G_TYPE_INVALID);
|
G_TYPE_INVALID);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -1438,9 +1430,3 @@ _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);
|
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);
|
|
||||||
}
|
|
||||||
|
@@ -132,7 +132,6 @@ G_DEFINE_TYPE_WITH_CODE (NMRemoteSettings, nm_remote_settings, G_TYPE_OBJECT,
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DBusGConnection *bus;
|
DBusGConnection *bus;
|
||||||
gboolean private_bus;
|
|
||||||
gboolean inited;
|
gboolean inited;
|
||||||
|
|
||||||
DBusGProxy *proxy;
|
DBusGProxy *proxy;
|
||||||
@@ -1177,7 +1176,6 @@ constructed (GObject *object)
|
|||||||
|
|
||||||
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
|
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
|
||||||
|
|
||||||
if (priv->private_bus == FALSE) {
|
|
||||||
/* D-Bus proxy for clearing connections on NameOwnerChanged */
|
/* D-Bus proxy for clearing connections on NameOwnerChanged */
|
||||||
priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->bus,
|
priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->bus,
|
||||||
DBUS_SERVICE_DBUS,
|
DBUS_SERVICE_DBUS,
|
||||||
@@ -1196,7 +1194,6 @@ constructed (GObject *object)
|
|||||||
"NameOwnerChanged",
|
"NameOwnerChanged",
|
||||||
G_CALLBACK (name_owner_changed),
|
G_CALLBACK (name_owner_changed),
|
||||||
object, NULL);
|
object, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
priv->proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
|
priv->proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
|
||||||
NM_DBUS_PATH_SETTINGS,
|
NM_DBUS_PATH_SETTINGS,
|
||||||
@@ -1239,7 +1236,6 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
|
|||||||
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
||||||
GHashTable *props;
|
GHashTable *props;
|
||||||
|
|
||||||
if (priv->private_bus == FALSE) {
|
|
||||||
if (!dbus_g_proxy_call (priv->dbus_proxy, "NameHasOwner", error,
|
if (!dbus_g_proxy_call (priv->dbus_proxy, "NameHasOwner", error,
|
||||||
G_TYPE_STRING, NM_DBUS_SERVICE,
|
G_TYPE_STRING, NM_DBUS_SERVICE,
|
||||||
G_TYPE_INVALID,
|
G_TYPE_INVALID,
|
||||||
@@ -1254,8 +1250,6 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
|
|||||||
*/
|
*/
|
||||||
if (!priv->service_running)
|
if (!priv->service_running)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else
|
|
||||||
priv->service_running = TRUE;
|
|
||||||
|
|
||||||
priv->listcon_call = dbus_g_proxy_begin_call (priv->proxy, "ListConnections",
|
priv->listcon_call = dbus_g_proxy_begin_call (priv->proxy, "ListConnections",
|
||||||
fetch_connections_done, NM_REMOTE_SETTINGS (initable), NULL,
|
fetch_connections_done, NM_REMOTE_SETTINGS (initable), NULL,
|
||||||
@@ -1376,17 +1370,12 @@ init_async (GAsyncInitable *initable, int io_priority,
|
|||||||
init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback,
|
init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback,
|
||||||
user_data, init_async);
|
user_data, init_async);
|
||||||
|
|
||||||
if (priv->private_bus) {
|
|
||||||
priv->service_running = TRUE;
|
|
||||||
init_get_properties (init_data);
|
|
||||||
} else {
|
|
||||||
/* Check if NM is running */
|
/* Check if NM is running */
|
||||||
dbus_g_proxy_begin_call (priv->dbus_proxy, "NameHasOwner",
|
dbus_g_proxy_begin_call (priv->dbus_proxy, "NameHasOwner",
|
||||||
init_async_got_manager_running,
|
init_async_got_manager_running,
|
||||||
init_data, NULL,
|
init_data, NULL,
|
||||||
G_TYPE_STRING, NM_DBUS_SERVICE,
|
G_TYPE_STRING, NM_DBUS_SERVICE,
|
||||||
G_TYPE_INVALID);
|
G_TYPE_INVALID);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -1444,10 +1433,8 @@ set_property (GObject *object, guint prop_id,
|
|||||||
case PROP_BUS:
|
case PROP_BUS:
|
||||||
/* Construct only */
|
/* Construct only */
|
||||||
priv->bus = g_value_dup_boxed (value);
|
priv->bus = g_value_dup_boxed (value);
|
||||||
if (!priv->bus) {
|
if (!priv->bus)
|
||||||
priv->bus = _nm_dbus_new_connection (NULL);
|
priv->bus = _nm_dbus_new_connection (NULL);
|
||||||
priv->private_bus = _nm_dbus_is_connection_private (priv->bus);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@@ -65,7 +65,6 @@ typedef struct {
|
|||||||
NMSecretAgentCapabilities capabilities;
|
NMSecretAgentCapabilities capabilities;
|
||||||
|
|
||||||
DBusGConnection *bus;
|
DBusGConnection *bus;
|
||||||
gboolean private_bus;
|
|
||||||
DBusGProxy *dbus_proxy;
|
DBusGProxy *dbus_proxy;
|
||||||
DBusGProxy *manager_proxy;
|
DBusGProxy *manager_proxy;
|
||||||
DBusGProxyCall *reg_call;
|
DBusGProxyCall *reg_call;
|
||||||
@@ -227,12 +226,6 @@ verify_sender (NMSecretAgent *self,
|
|||||||
|
|
||||||
g_return_val_if_fail (context != NULL, FALSE);
|
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
|
/* Verify the sender's UID is 0, and that the sender is the same as
|
||||||
* NetworkManager's bus name owner.
|
* NetworkManager's bus name owner.
|
||||||
*/
|
*/
|
||||||
@@ -626,7 +619,7 @@ nm_secret_agent_register (NMSecretAgent *self)
|
|||||||
g_return_val_if_fail (class->save_secrets != NULL, FALSE);
|
g_return_val_if_fail (class->save_secrets != NULL, FALSE);
|
||||||
g_return_val_if_fail (class->delete_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;
|
return FALSE;
|
||||||
|
|
||||||
priv->suppress_auto = FALSE;
|
priv->suppress_auto = FALSE;
|
||||||
@@ -671,7 +664,7 @@ nm_secret_agent_unregister (NMSecretAgent *self)
|
|||||||
g_return_val_if_fail (priv->bus != NULL, FALSE);
|
g_return_val_if_fail (priv->bus != NULL, FALSE);
|
||||||
g_return_val_if_fail (priv->manager_proxy != 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;
|
return FALSE;
|
||||||
|
|
||||||
dbus_g_proxy_call_no_reply (priv->manager_proxy, "Unregister", G_TYPE_INVALID);
|
dbus_g_proxy_call_no_reply (priv->manager_proxy, "Unregister", G_TYPE_INVALID);
|
||||||
@@ -853,9 +846,7 @@ nm_secret_agent_init (NMSecretAgent *self)
|
|||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return;
|
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,
|
priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->bus,
|
||||||
DBUS_SERVICE_DBUS,
|
DBUS_SERVICE_DBUS,
|
||||||
DBUS_PATH_DBUS,
|
DBUS_PATH_DBUS,
|
||||||
@@ -875,7 +866,6 @@ nm_secret_agent_init (NMSecretAgent *self)
|
|||||||
self, NULL);
|
self, NULL);
|
||||||
|
|
||||||
get_nm_owner (self);
|
get_nm_owner (self);
|
||||||
}
|
|
||||||
|
|
||||||
priv->manager_proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
|
priv->manager_proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
|
||||||
NM_DBUS_PATH_AGENT_MANAGER,
|
NM_DBUS_PATH_AGENT_MANAGER,
|
||||||
@@ -885,7 +875,7 @@ nm_secret_agent_init (NMSecretAgent *self)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->nm_owner || priv->private_bus)
|
if (priv->nm_owner)
|
||||||
priv->auto_register_id = g_idle_add (auto_register_cb, self);
|
priv->auto_register_id = g_idle_add (auto_register_cb, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user