agent-manager: if an agent returns UserCanceled, stop

If an agent returns a UserCanceled error in response to a secrets
request, don't ask any other remaining secret agents for secrets.
This commit is contained in:
Dan Winship 2013-11-25 13:54:59 -05:00
parent a8ef01b2c6
commit c9c6c73166
2 changed files with 13 additions and 3 deletions

View file

@ -815,8 +815,17 @@ get_done_cb (NMSecretAgent *agent,
req, parent->detail, req->setting_name,
error ? error->code : -1,
(error && error->message) ? error->message : "(unknown)");
/* Try the next agent */
request_next_agent (parent);
if (!dbus_g_error_has_name (error, NM_DBUS_INTERFACE_SECRET_AGENT ".UserCanceled")) {
error = g_error_new_literal (NM_AGENT_MANAGER_ERROR,
NM_AGENT_MANAGER_ERROR_USER_CANCELED,
"User canceled the secrets request.");
req_complete_error (parent, error);
g_error_free (error);
} else {
/* Try the next agent */
request_next_agent (parent);
}
return;
}

View file

@ -41,7 +41,8 @@ typedef enum {
NM_AGENT_MANAGER_ERROR_INVALID_IDENTIFIER, /*< nick=InvalidIdentifier >*/
NM_AGENT_MANAGER_ERROR_NOT_REGISTERED, /*< nick=NotRegistered >*/
NM_AGENT_MANAGER_ERROR_INTERNAL_ERROR, /*< nick=InternalError >*/
NM_AGENT_MANAGER_ERROR_NO_SECRETS /*< nick=NoSecrets >*/
NM_AGENT_MANAGER_ERROR_NO_SECRETS, /*< nick=NoSecrets >*/
NM_AGENT_MANAGER_ERROR_USER_CANCELED /*< nick=UserCanceled >*/
} NMAgentManagerError;
typedef struct {