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
This commit is contained in:
Dan Williams
2012-06-27 09:42:47 -05:00
parent c3b29cec71
commit 74e262b303
6 changed files with 22 additions and 2 deletions

View File

@@ -29,6 +29,7 @@ typedef enum {
NM_SETTINGS_GET_SECRETS_FLAG_NONE = 0x0, NM_SETTINGS_GET_SECRETS_FLAG_NONE = 0x0,
NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1, NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1,
NM_SETTINGS_GET_SECRETS_FLAG_REQUEST_NEW = 0x2, NM_SETTINGS_GET_SECRETS_FLAG_REQUEST_NEW = 0x2,
NM_SETTINGS_GET_SECRETS_FLAG_USER_REQUESTED = 0x4,
/* Internal only to NM */ /* Internal only to NM */
NM_SETTINGS_GET_SECRETS_FLAG_ONLY_SYSTEM = 0x80000000 NM_SETTINGS_GET_SECRETS_FLAG_ONLY_SYSTEM = 0x80000000

View File

@@ -96,6 +96,14 @@
invalid or wrong. This flag implies that interaction is allowed. invalid or wrong. This flag implies that interaction is allowed.
</tp:docstring> </tp:docstring>
</tp:flag> </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> </tp:flags>
<method name="CancelGetSecrets"> <method name="CancelGetSecrets">

View File

@@ -50,13 +50,18 @@ typedef enum {
* secrets from the user. This flag signals that NetworkManager thinks any * secrets from the user. This flag signals that NetworkManager thinks any
* existing secrets are invalid or wrong. This flag implies that interaction * existing secrets are invalid or wrong. This flag implies that interaction
* is allowed. * 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. * #NMSecretAgentGetSecretsFlags values modify the behavior of a GetSecrets request.
*/ */
typedef enum { typedef enum {
NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE = 0x0, NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE = 0x0,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1, 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; } NMSecretAgentGetSecretsFlags;
#define NM_TYPE_SECRET_AGENT (nm_secret_agent_get_type ()) #define NM_TYPE_SECRET_AGENT (nm_secret_agent_get_type ())

View File

@@ -130,6 +130,9 @@ nm_act_request_get_secrets (NMActRequest *self,
info->callback = callback; info->callback = callback;
info->callback_data = callback_data; 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), call_id = nm_settings_connection_get_secrets (NM_SETTINGS_CONNECTION (priv->connection),
priv->user_requested, priv->user_requested,
priv->user_uid, priv->user_uid,

View File

@@ -1355,7 +1355,7 @@ dbus_secrets_auth_cb (NMSettingsConnection *self,
TRUE, TRUE,
sender_uid, sender_uid,
setting_name, setting_name,
NM_SETTINGS_GET_SECRETS_FLAG_NONE, NM_SETTINGS_GET_SECRETS_FLAG_USER_REQUESTED,
NULL, NULL,
dbus_get_agent_secrets_cb, dbus_get_agent_secrets_cb,
context, context,

View File

@@ -1454,6 +1454,9 @@ get_secrets (NMVPNConnection *self, SecretsReq secrets_idx)
g_assert_not_reached (); 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), priv->secrets_id = nm_settings_connection_get_secrets (NM_SETTINGS_CONNECTION (priv->connection),
filter_by_uid, filter_by_uid,
priv->user_uid, priv->user_uid,