Commit 74e262b3 authored by Dan Williams's avatar Dan Williams

agents: add a "user-requested" flag to secret agent requests

Allows agents to provide different behavior depending on whether the
secrets request was initiated by a user (eg by picking a connection
from a UI menu or by 'nmcli con up') or was automatically started by
NetworkManager.

See https://bugzilla.gnome.org/show_bug.cgi?id=660293
parent c3b29cec
......@@ -29,6 +29,7 @@ typedef enum {
NM_SETTINGS_GET_SECRETS_FLAG_NONE = 0x0,
NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1,
NM_SETTINGS_GET_SECRETS_FLAG_REQUEST_NEW = 0x2,
NM_SETTINGS_GET_SECRETS_FLAG_USER_REQUESTED = 0x4,
/* Internal only to NM */
NM_SETTINGS_GET_SECRETS_FLAG_ONLY_SYSTEM = 0x80000000
......
......@@ -96,6 +96,14 @@
invalid or wrong. This flag implies that interaction is allowed.
</tp:docstring>
</tp:flag>
<tp:flag suffix="USER_REQUESTED" value="0x4">
<tp:docstring>
Set if the request was initiated by user-requested action via the
D-Bus interface, as opposed to automatically initiated by
NetworkManager in response to (for example) scan results or
carrier changes.
</tp:docstring>
</tp:flag>
</tp:flags>
<method name="CancelGetSecrets">
......
......@@ -50,13 +50,18 @@ typedef enum {
* secrets from the user. This flag signals that NetworkManager thinks any
* existing secrets are invalid or wrong. This flag implies that interaction
* is allowed.
* @NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED: set if the request was
* initiated by user-requested action via the D-Bus interface, as opposed to
* automatically initiated by NetworkManager in response to (for example) scan
* results or carrier changes.
*
* #NMSecretAgentGetSecretsFlags values modify the behavior of a GetSecrets request.
*/
typedef enum {
NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE = 0x0,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1,
NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW = 0x2
NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW = 0x2,
NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED = 0x4
} NMSecretAgentGetSecretsFlags;
#define NM_TYPE_SECRET_AGENT (nm_secret_agent_get_type ())
......
......@@ -130,6 +130,9 @@ nm_act_request_get_secrets (NMActRequest *self,
info->callback = callback;
info->callback_data = callback_data;
if (priv->user_requested)
flags |= NM_SETTINGS_GET_SECRETS_FLAG_USER_REQUESTED;
call_id = nm_settings_connection_get_secrets (NM_SETTINGS_CONNECTION (priv->connection),
priv->user_requested,
priv->user_uid,
......
......@@ -1355,7 +1355,7 @@ dbus_secrets_auth_cb (NMSettingsConnection *self,
TRUE,
sender_uid,
setting_name,
NM_SETTINGS_GET_SECRETS_FLAG_NONE,
NM_SETTINGS_GET_SECRETS_FLAG_USER_REQUESTED,
NULL,
dbus_get_agent_secrets_cb,
context,
......
......@@ -1454,6 +1454,9 @@ get_secrets (NMVPNConnection *self, SecretsReq secrets_idx)
g_assert_not_reached ();
}
if (priv->user_requested)
flags |= NM_SETTINGS_GET_SECRETS_FLAG_USER_REQUESTED;
priv->secrets_id = nm_settings_connection_get_secrets (NM_SETTINGS_CONNECTION (priv->connection),
filter_by_uid,
priv->user_uid,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment