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_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

View file

@ -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">

View file

@ -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 ())

View file

@ -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,

View file

@ -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,

View file

@ -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,