From 1dc8d416d40809214eaa97ae348ed4f38e64c78a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 17 Sep 2012 09:10:03 +0100 Subject: [PATCH 20/20] Default accounts backend: finish password migrations that Empathy 3.0 started Bug: https://bugs.freedesktop.org/show_bug.cgi?id=42088 --- src/mcd-account-manager-default.c | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/mcd-account-manager-default.c b/src/mcd-account-manager-default.c index cd6d019..0ae5027 100644 --- a/src/mcd-account-manager-default.c +++ b/src/mcd-account-manager-default.c @@ -20,7 +20,11 @@ */ #include "config.h" + #include + +#include + #include "mcd-account-manager-default.h" #include "mcd-debug.h" @@ -286,6 +290,57 @@ _get_secrets_from_keyring (const McpAccountStorage *self, g_warning ("Unsupported value type for %s.%s", account, name); } + if (!tp_strdiff (param, "password")) + { + /* Empathy 3.0 was meant to migrate passwords from MC to + * itself, but it couldn't complete the migration by + * deleting the password from MC, because MC had several + * bugs that meant deleting passwords didn't work. To atone + * for our past sins, detect an incomplete migration and + * complete it. */ + GnomeKeyringResult empathy_ok = + GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON; + GnomeKeyringAttributeList *empathy_match = + gnome_keyring_attribute_list_new (); + GList *empathy_items = NULL; + + gnome_keyring_attribute_list_append_string (empathy_match, + "account-id", account); + gnome_keyring_attribute_list_append_string (empathy_match, + "param-name", "password"); + + empathy_ok = gnome_keyring_find_items_sync ( + GNOME_KEYRING_ITEM_GENERIC_SECRET, empathy_match, + &empathy_items); + + if (empathy_ok == GNOME_KEYRING_RESULT_OK && + empathy_items != NULL) + { + KeyringSetData *ksd = g_slice_new0 (KeyringSetData); + + DEBUG ("An Empathy 3.0 password migration wasn't finished " + "due to MC bugs. Finishing it now by deleting the " + "password for %s", account); + + ksd->account = g_strdup (account); + ksd->name = g_strdup ("password"); + ksd->set = FALSE; + + gnome_keyring_delete_password (&keyring_schema, + _keyring_set_cb, ksd, NULL, + "account", account, + "param", "password", + NULL); + } + + gnome_keyring_found_list_free (empathy_items); + + /* behave as if it had already been deleted, i.e. we never + * actually found it... */ + param = NULL; + value = NULL; + } + if (param != NULL && value != NULL) { gchar *key = g_strdup_printf ("param-%s", param); -- 1.7.10.4