summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2022-10-22 11:18:01 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2022-10-24 18:10:49 +0200
commit1e51de5a211206a2c5ed096e943d18fc8de3cbfa (patch)
tree00f6b84c79a6fee9d16fe587e123e970c38b1b8a
parentb395c6959e113c54c4ab601aae02625007fdac3b (diff)
agent-manager: return all secrets if we don't need to ask agentsbg/agent-secrets
When the connection already has all needed secrets, _con_get_try_complete_early() returns `existing_secrets` without asking to agents; `existing_secrets` is initialized with system secrets. In NMSettingsConnection, get_secrets_done_cb() strips all secrets from the connection and then merges the secrets returned by nm_agent_manager_get_secrets(). Since nm_agent_manager_get_secrets() returns only system secrets, the result is that agent owned secrets are not asked to agents and are removed from the connection. Fix this by returning all secrets from the agent manager. https://gitlab.gnome.org/GNOME/network-manager-applet/-/issues/157
-rw-r--r--src/core/settings/nm-agent-manager.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/core/settings/nm-agent-manager.c b/src/core/settings/nm-agent-manager.c
index 295378bc86..8ddeea3ecd 100644
--- a/src/core/settings/nm-agent-manager.c
+++ b/src/core/settings/nm-agent-manager.c
@@ -1142,8 +1142,10 @@ _con_get_try_complete_early(Request *req)
gs_unref_variant GVariant *setting_secrets = NULL;
gs_unref_object NMConnection *tmp = NULL;
GError *error = NULL;
+ gboolean only_system;
- self = req->self;
+ self = req->self;
+ only_system = NM_FLAGS_HAS(req->con.get.flags, NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM);
/* Check if there are any existing secrets */
if (req->con.get.existing_secrets)
@@ -1171,13 +1173,24 @@ _con_get_try_complete_early(Request *req)
return TRUE;
}
/* Do we have everything we need? */
- if (NM_FLAGS_HAS(req->con.get.flags, NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM)
+ if (only_system
|| ((nm_connection_need_secrets(tmp, NULL) == NULL)
&& !NM_FLAGS_HAS(req->con.get.flags, NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW))) {
+ GVariant *secrets;
+ gs_unref_variant GVariant *secrets_free = NULL;
+
_LOGD(NULL, "(" LOG_REQ_FMT ") system settings secrets sufficient", LOG_REQ_ARG(req));
+ if (only_system)
+ secrets = req->con.get.existing_secrets;
+ else {
+ secrets = g_variant_ref_sink(
+ nm_connection_to_dbus(tmp, NM_CONNECTION_SERIALIZE_ONLY_SECRETS));
+ secrets_free = secrets;
+ }
+
/* Got everything, we're done */
- req_complete(req, req->con.get.existing_secrets, NULL, NULL, NULL);
+ req_complete(req, secrets, NULL, NULL, NULL);
return TRUE;
}