[telepathy-mission-control-5.12] telepathy-mission-control: Default account backend: when deleting, always delete from both places

Simon McVittie smcv at kemper.freedesktop.org
Thu Sep 6 10:00:40 PDT 2012


Module: telepathy-mission-control
Branch: telepathy-mission-control-5.12
Commit: dbba880903def15bc7bb5fdb9d05ee310f1a5bfe
URL:    http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=dbba880903def15bc7bb5fdb9d05ee310f1a5bfe

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Thu Aug 30 18:09:21 2012 +0100

Default account backend: when deleting, always delete from both places

Our tracking of whether something is "secret" (in the gnome-keyring) is
pretty shaky, and in particular, we can forget that things are meant
to be "secret" sometimes (we lose that information when deleting
parameters).

Happily, when we're deleting things, it doesn't actually matter: the
right thing to do is clearly to delete from both locations, regardless
of where we think it ought to be.

Similarly, when we're setting a property to a new value, it's appropriate
to delete it from both locations, then put it in the right location
(only).

Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Reviewed-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=42088
Cherry-picked-from: 5b4954d2c959c4ba7f6c67b7d8e16eaa5ab272dd

---

 src/mcd-account-manager-default.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/mcd-account-manager-default.c b/src/mcd-account-manager-default.c
index e156de1..221c5d0 100644
--- a/src/mcd-account-manager-default.c
+++ b/src/mcd-account-manager-default.c
@@ -411,6 +411,10 @@ _set (const McpAccountStorage *self,
   /* if we have a keyring, secrets are segregated */
   secret = mcp_account_manager_parameter_is_secret (am, account, key);
 
+  /* remove it from both sets, then re-add it to the right one if non-null */
+  g_key_file_remove_key (amd->secrets, account, key, NULL);
+  g_key_file_remove_key (amd->keyfile, account, key, NULL);
+
   if (val != NULL)
     {
       if (secret)
@@ -418,13 +422,6 @@ _set (const McpAccountStorage *self,
       else
         g_key_file_set_value (amd->keyfile, account, key, val);
     }
-  else
-    {
-      if (secret)
-        g_key_file_remove_key (amd->secrets, account, key, NULL);
-      else
-        g_key_file_remove_key (amd->keyfile, account, key, NULL);
-    }
 
   /* if we removed the account before, it now exists again, so... */
   g_hash_table_remove (amd->removed_accounts, account);
@@ -561,8 +558,10 @@ _delete (const McpAccountStorage *self,
           g_key_file_remove_group (amd->keyfile, account, NULL);
           _delete_from_keyring (self, am, account, NULL);
         }
-      else if (mcp_account_manager_parameter_is_secret (am, account, key))
+      else
         {
+          /* always delete from keyring, even if we didn't previously
+           * think it was secret - we might have been wrong */
           _delete_from_keyring (self, am, account, key);
         }
 



More information about the telepathy-commits mailing list