[network-manager-applet] agent: save updated secrets before sending to NetworkManager
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet] agent: save updated secrets before sending to NetworkManager
- Date: Thu, 14 Jul 2011 03:13:25 +0000 (UTC)
commit 41dfbc92f934645bee3615f17a0c1cda0f1d4015
Author: Dan Williams <dcbw redhat com>
Date: Wed Jul 13 16:49:19 2011 -0500
agent: save updated secrets before sending to NetworkManager
When updated secrets are retrieved during a GetSecrets we need to
save them, since we are the agent, and the agent is expected to
save secrets it controls. NetworkManager will not send a SaveSecrets
request for agent-owned secrets as a result of a GetSecrets request.
This ensures that agent-owned VPN and 802.1x secrets (and any other
agent-owned secrets) are saved to GConf when entered by the user such
as when the secret is requested for the first time.
src/applet-agent.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/src/applet-agent.c b/src/applet-agent.c
index 5b8a828..3ed3944 100644
--- a/src/applet-agent.c
+++ b/src/applet-agent.c
@@ -162,6 +162,15 @@ keyring_call_free (gpointer data)
/*******************************************************/
static void
+get_save_cb (NMSecretAgent *agent,
+ NMConnection *connection,
+ GError *error,
+ gpointer user_data)
+{
+ /* Ignored */
+}
+
+static void
get_secrets_cb (AppletAgent *self,
GHashTable *secrets,
GError *error,
@@ -169,8 +178,35 @@ get_secrets_cb (AppletAgent *self,
{
Request *r = user_data;
- if (r->canceled == FALSE)
- r->get_callback (NM_SECRET_AGENT (r->agent), r->connection, error ? NULL : secrets, error, r->callback_data);
+ /* 'secrets' shouldn't be valid if there was an error */
+ if (error) {
+ g_warn_if_fail (secrets == NULL);
+ secrets = NULL;
+ }
+
+ if (r->canceled == FALSE) {
+ /* Save updated secrets as long as user-interaction was allowed; otherwise
+ * we'd be saving secrets we just pulled out of the keyring which is somewhat
+ * redundant.
+ */
+ if (secrets && (r->flags != NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE)) {
+ NMConnection *dup;
+ GHashTableIter iter;
+ const char *setting_name;
+
+ /* Copy the existing connection and update its secrets */
+ dup = nm_connection_duplicate (r->connection);
+ g_hash_table_iter_init (&iter, secrets);
+ while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, NULL))
+ nm_connection_update_secrets (dup, setting_name, secrets, NULL);
+
+ /* And save updated secrets to the keyring */
+ nm_secret_agent_save_secrets (NM_SECRET_AGENT (self), dup, get_save_cb, NULL);
+ g_object_unref (dup);
+ }
+
+ r->get_callback (NM_SECRET_AGENT (r->agent), r->connection, secrets, error, r->callback_data);
+ }
request_free (r);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]