diff options
author | Thomas Haller <thaller@redhat.com> | 2019-06-16 21:25:09 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-06-16 21:25:09 +0200 |
commit | 6c42b5caafe6aab9f86f98c4fdf6b2145cb4b972 (patch) | |
tree | 2a18e0ed2672de7e995c8d9551f3b814b722dbbc | |
parent | bf6358e071424ea3fdf35a7373c1822387cdb7a6 (diff) | |
download | NetworkManager-th/various-settings-cleanup-2.tar.gz |
settings: avoid cloning the connection to maintain agent-owned secretsth/various-settings-cleanup-2
-rw-r--r-- | src/settings/nm-settings-connection.c | 15 | ||||
-rw-r--r-- | src/settings/nm-settings.c | 8 |
2 files changed, 8 insertions, 15 deletions
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index 0883d5e7fd..ab9df65429 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -482,7 +482,6 @@ nm_settings_connection_update (NMSettingsConnection *self, gboolean replaced = FALSE; gs_free char *logmsg_change = NULL; GError *local = NULL; - gs_unref_object NMConnection *simple = NULL; gs_unref_variant GVariant *con_agent_secrets = NULL; gs_unref_variant GVariant *new_agent_secrets = NULL; @@ -527,11 +526,8 @@ nm_settings_connection_update (NMSettingsConnection *self, /* Save agent-owned secrets from the new connection for later use */ if (new_connection) { - simple = nm_simple_connection_new_clone (new_connection); - _nm_connection_clear_secrets_by_secret_flags (simple, - NM_SETTING_SECRET_FLAG_AGENT_OWNED); - new_agent_secrets = nm_connection_to_dbus (simple, NM_CONNECTION_SERIALIZE_ONLY_SECRETS); - g_clear_object (&simple); + new_agent_secrets = nm_connection_to_dbus (new_connection, NM_CONNECTION_SERIALIZE_ONLY_SECRETS + | NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED); } /* Disconnect the changed signal to ensure we don't set Unsaved when @@ -553,10 +549,9 @@ nm_settings_connection_update (NMSettingsConnection *self, /* Make a copy of agent-owned secrets because they won't be present in * the connection returned by plugins, as plugins return only what was * reread from the file. */ - simple = nm_simple_connection_new_clone (nm_settings_connection_get_connection (self)); - _nm_connection_clear_secrets_by_secret_flags (simple, - NM_SETTING_SECRET_FLAG_AGENT_OWNED); - con_agent_secrets = nm_connection_to_dbus (simple, NM_CONNECTION_SERIALIZE_ONLY_SECRETS); + con_agent_secrets = nm_connection_to_dbus (nm_settings_connection_get_connection (self), + NM_CONNECTION_SERIALIZE_ONLY_SECRETS + | NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED); nm_connection_replace_settings_from_connection (nm_settings_connection_get_connection (self), replace_connection); diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 8229dbca86..1c259be98a 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -589,16 +589,14 @@ nm_settings_add_connection (NMSettings *self, for (iter = priv->plugins; iter; iter = g_slist_next (iter)) { NMSettingsPlugin *plugin = NM_SETTINGS_PLUGIN (iter->data); GError *add_error = NULL; - gs_unref_object NMConnection *simple = NULL; gs_unref_variant GVariant *secrets = NULL; /* Make a copy of agent-owned secrets because they won't be present in * the connection returned by plugins, as plugins return only what was * reread from the file. */ - simple = nm_simple_connection_new_clone (connection); - _nm_connection_clear_secrets_by_secret_flags (simple, - NM_SETTING_SECRET_FLAG_AGENT_OWNED); - secrets = nm_connection_to_dbus (simple, NM_CONNECTION_SERIALIZE_ONLY_SECRETS); + secrets = nm_connection_to_dbus (connection, + NM_CONNECTION_SERIALIZE_ONLY_SECRETS + | NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED); added = nm_settings_plugin_add_connection (plugin, connection, save_to_disk, &add_error); if (added) { |