diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2018-02-14 11:43:00 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2018-02-14 11:49:39 +0100 |
commit | f9c50bf3d3e1e52d5803d55fa97bf56930fd3020 (patch) | |
tree | 779440e1ec87271ddee634c6e88e84fe37ed4d23 | |
parent | e27963d17ff45ccb5ab71f932d6ed17a59380ec6 (diff) |
settings: preserve agent-owned secrets on connection update
After writing the connection to disk and rereading it, in addition to
restoring agent-owned secrets in the cache we must also restore
agent-owned secrets from the original connections since they are lost
during the write.
Reported-by: Märt Bakhoff <anon@sigil.red>
https://bugzilla.gnome.org/show_bug.cgi?id=793324
-rw-r--r-- | src/settings/nm-settings-connection.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index 277e1eeb3a..c499dbfe38 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -604,6 +604,7 @@ nm_settings_connection_update (NMSettingsConnection *self, gboolean replaced = FALSE; gs_free char *logmsg_change = NULL; GError *local = NULL; + gs_unref_variant GVariant *con_agent_secrets = NULL; g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), FALSE); @@ -654,9 +655,20 @@ nm_settings_connection_update (NMSettingsConnection *self, && !nm_connection_compare (NM_CONNECTION (self), replace_connection, NM_SETTING_COMPARE_FLAG_EXACT)) { + gs_unref_object NMConnection *simple = NULL; + if (log_diff_name) nm_utils_log_connection_diff (replace_connection, NM_CONNECTION (self), LOGL_DEBUG, LOGD_CORE, log_diff_name, "++ "); + /* 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_CONNECTION (self)); + nm_connection_clear_secrets_with_flags (simple, + secrets_filter_cb, + GUINT_TO_POINTER (NM_SETTING_SECRET_FLAG_AGENT_OWNED)); + con_agent_secrets = nm_connection_to_dbus (simple, NM_CONNECTION_SERIALIZE_ONLY_SECRETS); + nm_connection_replace_settings_from_connection (NM_CONNECTION (self), replace_connection); replaced = TRUE; @@ -684,6 +696,8 @@ nm_settings_connection_update (NMSettingsConnection *self, g_variant_unref (dict); } } + if (con_agent_secrets) + (void) nm_connection_update_secrets (NM_CONNECTION (self), NULL, con_agent_secrets, NULL); } nm_settings_connection_recheck_visibility (self); |