agents: only commit connection changes if there were system secrets
It's pointless to save the connection if there weren't any system secrets being changed.
This commit is contained in:
@@ -501,6 +501,7 @@ agent_secrets_done_cb (NMAgentManager *manager,
|
|||||||
gpointer callback_data = other_data3;
|
gpointer callback_data = other_data3;
|
||||||
GError *local = NULL;
|
GError *local = NULL;
|
||||||
GHashTable *hash;
|
GHashTable *hash;
|
||||||
|
gboolean agent_had_system = FALSE;
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets request error: (%d) %s",
|
nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets request error: (%d) %s",
|
||||||
@@ -525,8 +526,6 @@ agent_secrets_done_cb (NMAgentManager *manager,
|
|||||||
|
|
||||||
g_assert (secrets);
|
g_assert (secrets);
|
||||||
if (agent_dbus_owner) {
|
if (agent_dbus_owner) {
|
||||||
gboolean has_system = FALSE;
|
|
||||||
|
|
||||||
nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets returned from agent %s",
|
nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets returned from agent %s",
|
||||||
nm_connection_get_uuid (NM_CONNECTION (self)),
|
nm_connection_get_uuid (NM_CONNECTION (self)),
|
||||||
setting_name,
|
setting_name,
|
||||||
@@ -539,8 +538,8 @@ agent_secrets_done_cb (NMAgentManager *manager,
|
|||||||
* save those system-owned secrets. If not, discard them and use the
|
* save those system-owned secrets. If not, discard them and use the
|
||||||
* existing secrets, or fail the connection.
|
* existing secrets, or fail the connection.
|
||||||
*/
|
*/
|
||||||
for_each_secret (NM_CONNECTION (self), secrets, has_system_owned_secrets, &has_system);
|
for_each_secret (NM_CONNECTION (self), secrets, has_system_owned_secrets, &agent_had_system);
|
||||||
if (has_system) {
|
if (agent_had_system) {
|
||||||
if (flags == 0) { /* ie SECRETS_FLAG_NONE */
|
if (flags == 0) { /* ie SECRETS_FLAG_NONE */
|
||||||
/* No user interaction was allowed when requesting secrets; the
|
/* No user interaction was allowed when requesting secrets; the
|
||||||
* agent is being bad. Remove system-owned secrets.
|
* agent is being bad. Remove system-owned secrets.
|
||||||
@@ -597,12 +596,24 @@ agent_secrets_done_cb (NMAgentManager *manager,
|
|||||||
*/
|
*/
|
||||||
update_secrets_cache (self);
|
update_secrets_cache (self);
|
||||||
|
|
||||||
nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) saving new secrets to backing storage",
|
/* Only save secrets to backing storage if the agent returned any
|
||||||
nm_connection_get_uuid (NM_CONNECTION (self)),
|
* new system secrets. If it didn't, then the secrets are agent-
|
||||||
setting_name,
|
* owned and there's no point to writing out the connection when
|
||||||
call_id);
|
* nothing has changed, since agent-owned secrets don't get saved here.
|
||||||
|
*/
|
||||||
|
if (agent_had_system) {
|
||||||
|
nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) saving new secrets to backing storage",
|
||||||
|
nm_connection_get_uuid (NM_CONNECTION (self)),
|
||||||
|
setting_name,
|
||||||
|
call_id);
|
||||||
|
|
||||||
nm_settings_connection_commit_changes (self, new_secrets_commit_cb, NULL);
|
nm_settings_connection_commit_changes (self, new_secrets_commit_cb, NULL);
|
||||||
|
} else {
|
||||||
|
nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) new agent secrets processed",
|
||||||
|
nm_connection_get_uuid (NM_CONNECTION (self)),
|
||||||
|
setting_name,
|
||||||
|
call_id);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) failed to update with agent secrets: (%d) %s",
|
nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) failed to update with agent secrets: (%d) %s",
|
||||||
nm_connection_get_uuid (NM_CONNECTION (self)),
|
nm_connection_get_uuid (NM_CONNECTION (self)),
|
||||||
|
Reference in New Issue
Block a user