summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-06-20 15:37:44 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2016-06-21 10:08:46 +0200
commit67d933d6afdf8e04ea95b6a0d43a4ea665915c60 (patch)
treea653895f260f85992b6833a7fe3b9287b1e402dd
parent46d7348440d79abb30e41e3324741f8fe2bc7771 (diff)
downloadNetworkManager-bg/secret-timeout-bgo767321.tar.gz
secrets: call CancelGetSecrets after a timeout in secret requestbg/secret-timeout-bgo767321
When a call to GetSecrets fails due to timeout, we have to notify the agent that we're not interested in the secrets anymore, so that any pending authentication dialog can show the proper message to user. This was already the normal behavior before commit 92dda6472cb8 ("secret-agent: rework handling of asynchronous request and cancelling"). The existing code in nm-agent-manager.c which supposedly does this is never reached and the secret agent seems a better place to implement the cancellation after a timeout. Fixes: 92dda6472cb881fc9965a014f16ffabb370b1e55
-rw-r--r--src/settings/nm-agent-manager.c5
-rw-r--r--src/settings/nm-secret-agent.c16
2 files changed, 15 insertions, 6 deletions
diff --git a/src/settings/nm-agent-manager.c b/src/settings/nm-agent-manager.c
index 54ca2f55c5..04b1248575 100644
--- a/src/settings/nm-agent-manager.c
+++ b/src/settings/nm-agent-manager.c
@@ -857,11 +857,6 @@ _con_get_request_done (NMSecretAgent *agent,
req_complete_error (req, error);
g_error_free (error);
} else {
- if (req->current_call_id) {
- /* Tell the failed agent we're no longer interested. */
- nm_secret_agent_cancel_secrets (req->current, req->current_call_id);
- }
-
/* Try the next agent */
request_next_agent (req);
maybe_remove_agent_on_error (agent, error);
diff --git a/src/settings/nm-secret-agent.c b/src/settings/nm-secret-agent.c
index b2e38b682f..f29c44f912 100644
--- a/src/settings/nm-secret-agent.c
+++ b/src/settings/nm-secret-agent.c
@@ -84,6 +84,8 @@ enum {
};
static guint signals[LAST_SIGNAL] = { 0 };
+static void cancel_with_reason_done (GObject *proxy, GAsyncResult *result, gpointer user_data);
+
/*************************************************************/
struct _NMSecretAgentCallId {
@@ -345,6 +347,7 @@ get_callback (GObject *proxy,
gpointer user_data)
{
Request *r = user_data;
+ CancelInfo *info;
if (request_check_return (r)) {
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (r->agent);
@@ -352,8 +355,19 @@ get_callback (GObject *proxy,
gs_unref_variant GVariant *secrets = NULL;
nmdbus_secret_agent_call_get_secrets_finish (priv->proxy, &secrets, result, &error);
- if (error)
+ if (error) {
g_dbus_error_strip_remote_error (error);
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_TIMED_OUT)) {
+ /* Tell the failed agent we're no longer interested */
+ info = cancel_info_new (r->agent, r->setting_name, r->path);
+ nmdbus_secret_agent_call_cancel_get_secrets_with_reason (priv->proxy,
+ r->path, r->setting_name,
+ NM_SECRET_AGENT_CANCEL_REASON_TIMED_OUT,
+ NULL,
+ cancel_with_reason_done,
+ info);
+ }
+ }
r->callback (r->agent, r, secrets, error, r->callback_data);
}