summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-09-13 14:35:55 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2016-09-14 23:34:25 +0200
commitf3099db28e193a4c3736a651af2d10102cc39853 (patch)
tree21b7813cff1b6ac0a33bc06ef50d6c0d49e7728c
parent2c1adaae5e3bd838c5735209caabcab430a781d9 (diff)
downloadNetworkManager-f3099db28e193a4c3736a651af2d10102cc39853.tar.gz
clients: handle secret requests only for current connection
The path was checked only when serving the enqueued requests but not for new ones. Fix this by moving the check to request_secrets_from_ui(). Fixes: 991df804086c4a1cee393d6d7182fa40cbba5dd7 https://bugzilla.redhat.com/show_bug.cgi?id=1351272
-rw-r--r--clients/common/nm-secret-agent-simple.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/clients/common/nm-secret-agent-simple.c b/clients/common/nm-secret-agent-simple.c
index cf4abf9042..0c90eba36e 100644
--- a/clients/common/nm-secret-agent-simple.c
+++ b/clients/common/nm-secret-agent-simple.c
@@ -428,11 +428,28 @@ static void
request_secrets_from_ui (NMSecretAgentSimpleRequest *request)
{
GPtrArray *secrets;
+ NMSecretAgentSimplePrivate *priv;
NMSecretAgentSimpleSecret *secret;
const char *title;
char *msg;
gboolean ok = TRUE;
+ priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE (request->self);
+ g_return_if_fail (priv->enabled);
+
+ /* We only handle requests for connection with @path if set. */
+ if (!g_str_has_prefix (request->request_id, priv->path)) {
+ gs_free_error GError *error = NULL;
+
+ error = g_error_new (NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_FAILED,
+ "Request for %s secrets doesn't match path %s",
+ request->request_id, priv->path);
+ request->callback (NM_SECRET_AGENT_OLD (request->self), request->connection,
+ NULL, error, request->callback_data);
+ g_hash_table_remove (priv->requests, request->request_id);
+ return;
+ }
+
secrets = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_secret_agent_simple_secret_free);
if (nm_connection_is_type (request->connection, NM_SETTING_WIRELESS_SETTING_NAME)) {
@@ -734,7 +751,6 @@ nm_secret_agent_simple_enable (NMSecretAgentSimple *self, const char *path)
{
NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE (self);
GList *requests, *iter;
- GError *error;
if (g_strcmp0 (path, priv->path) != 0) {
g_free (priv->path);
@@ -747,21 +763,9 @@ nm_secret_agent_simple_enable (NMSecretAgentSimple *self, const char *path)
/* Service pending secret requests. */
requests = g_hash_table_get_values (priv->requests);
- for (iter = requests; iter; iter = g_list_next (iter)) {
- NMSecretAgentSimpleRequest *request = iter->data;
+ for (iter = requests; iter; iter = g_list_next (iter))
+ request_secrets_from_ui (iter->data);
- if (g_str_has_prefix (request->request_id, priv->path)) {
- request_secrets_from_ui (request);
- } else {
- /* We only handle requests for connection with @path if set. */
- error = g_error_new (NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_FAILED,
- "Request for %s secrets doesn't match path %s",
- request->request_id, priv->path);
- request->callback (NM_SECRET_AGENT_OLD (self), request->connection, NULL, error, request->callback_data);
- g_hash_table_remove (priv->requests, request->request_id);
- g_error_free (error);
- }
- }
g_list_free (requests);
}