mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 13:50:15 +01:00
core: fix NMManager in private-bus-only case
NMManager was failing to initialize if there was only a private bus,
despite the fact that this is exactly the use case that the private
bus was added for.
The only other potentially-failing code in nm_manager_new() was adding
prop_filter to the D-Bus connection, but this can't really fail, so
just assert that it doesn't. And now, nm_manager_new() always
succeeds, so update the caller for that.
(cherry picked from commit 1c11c5cff1)
This commit is contained in:
parent
5d6b1bce8e
commit
431bbb01b4
3 changed files with 15 additions and 45 deletions
|
|
@ -476,13 +476,7 @@ main (int argc, char *argv[])
|
|||
net_enabled,
|
||||
wifi_enabled,
|
||||
wwan_enabled,
|
||||
wimax_enabled,
|
||||
&error);
|
||||
if (manager == NULL) {
|
||||
nm_log_err (LOGD_CORE, "failed to initialize the network manager: %s",
|
||||
error && error->message ? error->message : "(unknown)");
|
||||
goto done;
|
||||
}
|
||||
wimax_enabled);
|
||||
|
||||
/* Initialize the supplicant manager */
|
||||
sup_mgr = nm_supplicant_manager_get ();
|
||||
|
|
|
|||
|
|
@ -171,7 +171,6 @@ typedef struct {
|
|||
NMPolicy *policy;
|
||||
|
||||
NMDBusManager *dbus_mgr;
|
||||
gboolean prop_filter_added;
|
||||
NMRfkillManager *rfkill_mgr;
|
||||
|
||||
NMSettings *settings;
|
||||
|
|
@ -4671,17 +4670,13 @@ dbus_connection_changed_cb (NMDBusManager *dbus_mgr,
|
|||
gpointer user_data)
|
||||
{
|
||||
NMManager *self = NM_MANAGER (user_data);
|
||||
gboolean success = FALSE;
|
||||
gboolean success;
|
||||
|
||||
if (dbus_connection) {
|
||||
/* Register property filter on new connection; there's no reason this
|
||||
* should fail except out-of-memory or program error; if it does fail
|
||||
* then there's no Manager property access control, which is bad.
|
||||
*/
|
||||
/* Only fails on ENOMEM */
|
||||
success = dbus_connection_add_filter (dbus_connection, prop_filter, self, NULL);
|
||||
g_assert (success);
|
||||
}
|
||||
NM_MANAGER_GET_PRIVATE (self)->prop_filter_added = success;
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
|
@ -4709,11 +4704,9 @@ nm_manager_new (NMSettings *settings,
|
|||
gboolean initial_net_enabled,
|
||||
gboolean initial_wifi_enabled,
|
||||
gboolean initial_wwan_enabled,
|
||||
gboolean initial_wimax_enabled,
|
||||
GError **error)
|
||||
gboolean initial_wimax_enabled)
|
||||
{
|
||||
NMManagerPrivate *priv;
|
||||
DBusGConnection *bus;
|
||||
DBusConnection *dbus_connection;
|
||||
NMConfigData *config_data;
|
||||
|
||||
|
|
@ -4726,16 +4719,14 @@ nm_manager_new (NMSettings *settings,
|
|||
|
||||
priv = NM_MANAGER_GET_PRIVATE (singleton);
|
||||
|
||||
bus = nm_dbus_manager_get_connection (priv->dbus_mgr);
|
||||
if (!bus) {
|
||||
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED,
|
||||
"Failed to initialize D-Bus connection");
|
||||
g_object_unref (singleton);
|
||||
return NULL;
|
||||
}
|
||||
dbus_connection = nm_dbus_manager_get_dbus_connection (priv->dbus_mgr);
|
||||
if (dbus_connection) {
|
||||
gboolean success;
|
||||
|
||||
dbus_connection = dbus_g_connection_get_connection (bus);
|
||||
g_assert (dbus_connection);
|
||||
/* Only fails on ENOMEM */
|
||||
success = dbus_connection_add_filter (dbus_connection, prop_filter, singleton, NULL);
|
||||
g_assert (success);
|
||||
}
|
||||
|
||||
priv->policy = nm_policy_new (singleton, settings);
|
||||
g_signal_connect (priv->policy, "notify::" NM_POLICY_DEFAULT_IP4_DEVICE,
|
||||
|
|
@ -4760,14 +4751,6 @@ nm_manager_new (NMSettings *settings,
|
|||
g_signal_connect (priv->connectivity, "notify::" NM_CONNECTIVITY_STATE,
|
||||
G_CALLBACK (connectivity_changed), singleton);
|
||||
|
||||
if (!dbus_connection_add_filter (dbus_connection, prop_filter, singleton, NULL)) {
|
||||
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED,
|
||||
"Failed to register DBus connection filter");
|
||||
g_object_unref (singleton);
|
||||
return NULL;
|
||||
}
|
||||
priv->prop_filter_added = TRUE;
|
||||
|
||||
priv->settings = g_object_ref (settings);
|
||||
g_signal_connect (priv->settings, "notify::" NM_SETTINGS_STARTUP_COMPLETE,
|
||||
G_CALLBACK (settings_startup_complete_changed), singleton);
|
||||
|
|
@ -5064,7 +5047,6 @@ dispose (GObject *object)
|
|||
{
|
||||
NMManager *manager = NM_MANAGER (object);
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
DBusGConnection *bus;
|
||||
DBusConnection *dbus_connection;
|
||||
|
||||
g_slist_free_full (priv->auth_chains, (GDestroyNotify) nm_auth_chain_unref);
|
||||
|
|
@ -5110,14 +5092,9 @@ dispose (GObject *object)
|
|||
|
||||
/* Unregister property filter */
|
||||
if (priv->dbus_mgr) {
|
||||
bus = nm_dbus_manager_get_connection (priv->dbus_mgr);
|
||||
if (bus) {
|
||||
dbus_connection = dbus_g_connection_get_connection (bus);
|
||||
if (dbus_connection && priv->prop_filter_added) {
|
||||
dbus_connection_remove_filter (dbus_connection, prop_filter, manager);
|
||||
priv->prop_filter_added = FALSE;
|
||||
}
|
||||
}
|
||||
dbus_connection = nm_dbus_manager_get_dbus_connection (priv->dbus_mgr);
|
||||
if (dbus_connection)
|
||||
dbus_connection_remove_filter (dbus_connection, prop_filter, manager);
|
||||
g_signal_handlers_disconnect_by_func (priv->dbus_mgr, dbus_connection_changed_cb, manager);
|
||||
priv->dbus_mgr = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ NMManager * nm_manager_new (NMSettings *settings,
|
|||
gboolean initial_net_enabled,
|
||||
gboolean initial_wifi_enabled,
|
||||
gboolean initial_wwan_enabled,
|
||||
gboolean initial_wimax_enabled,
|
||||
GError **error);
|
||||
gboolean initial_wimax_enabled);
|
||||
|
||||
NMManager * nm_manager_get (void);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue