Bug 59468 - gnome keyring secrets can not be accessed after reboot
Summary: gnome keyring secrets can not be accessed after reboot
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: mission-control (show other bugs)
Version: git master
Hardware: All All
: medium major
Assignee: Simon McVittie
QA Contact: Telepathy bugs list
URL:
Whiteboard: review?
Keywords: patch
Depends on:
Blocks:
 
Reported: 2013-01-16 14:25 UTC by Simon Schampijer
Modified: 2013-05-01 19:04 UTC (History)
5 users (show)

See Also:
i915 platform:
i915 features:


Attachments
default.keyring with secret (507 bytes, text/plain)
2013-01-16 14:58 UTC, Simon Schampijer
Details
proposed patch for 5.12.x (1.99 KB, patch)
2013-01-16 17:22 UTC, Simon McVittie
Details | Splinter Review

Description Simon Schampijer 2013-01-16 14:25:27 UTC
When establishing the connection with the jabber server the first time everything works fine, the connection can be made and using the mc-tool the password for that account is shown correctly.

After reboot, the connection can not be established again. Using 'mc-tool show <account name>' does not show the password anymore. One can connect to the jabber server by using 'mc-tool update <Account> string:password=<secret from default-keyring>' and passing the password by hand.

Version:
    telepathy-mission-control: 5.14
    telepathy-glib: 0.20
    telepathy-gabble: 0.16.4
    gnome-keyring: 3.6
    libgnome-keyring: 3.6

I did downgrade to telepathy-gabble-0.16, telepathy-mission-control-5.12, telepathy-glib-0.18 and the issue was gone.

Adding debug logs we point at http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?h=telepathy-mission-control-5.14&id=eaefb264316f206186b2ac7f1f36e6a4692deb3d at second boot, ending up in '/* behave as if it had already been deleted, i.e. we never * actually found it... */'.

Full history and more info at: http://bugs.sugarlabs.org/ticket/4369
Comment 1 Simon McVittie 2013-01-16 14:58:04 UTC
Modern versions of both Empathy and KDE-Telepathy implement a SASLAuthentication channel handler[1], which means MC never needs to store (or see) your password. Ideally, Sugar should do the same, one day. I realise that's not something that can be implemented instantly, though.

[1] http://telepathy.freedesktop.org/spec/Channel_Interface_SASL_Authentication.html

The Empathy implementation of SASLAuthentication also uses gnome-keyring, and will automatically migrate accounts' passwords from MC's gnome-keyring "schema" to its own. Until recently, a MC bug broke that migration (Bug #42088) which is why MC now has code to recover from that bug.

Eventually, Mission Control will stop storing passwords in gnome-keyring, and just store them in clear-text (if told to store them at all). This is not really a security regression, given that a password stored in MC can be retrieved from it over D-Bus by getting the value of the Parameters property...

However, at the moment its behaviour is inconsistent:

* if asked to store a password (by putting {"password": "s3kr1t"} in Parameters), it will store it in gnome-keyring;
* but on subsequent startups, it will behave as if that password had not been stored in gnome-keyring.

You could try having it only ignore the stored password if Empathy's automatic migration has taken place, like this:

 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 fd.o #42088. 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);
+
+    /* behave as if it had already been deleted, i.e. we never
+     * actually found it... */
+    param = NULL;
+    value = 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;

A regression test would also be very welcome.
Comment 2 Simon Schampijer 2013-01-16 14:58:14 UTC
Created attachment 73150 [details]
default.keyring with secret

This is the default keyring that is stored on the device. It contains the password fine.
Comment 3 Simon McVittie 2013-01-16 15:02:05 UTC
(In reply to comment #0)
> I did downgrade to telepathy-gabble-0.16, telepathy-mission-control-5.12,
> telepathy-glib-0.18 and the issue was gone.

You must have been using an outdated version of telepathy-mission-control from the 5.12 branch - 5.12.3 has the same code for this as 5.14.x. I think the same change ought to work on that branch too.
Comment 4 Simon Schampijer 2013-01-16 15:05:24 UTC
Thanks Simon for the quick reply!

(In reply to comment #3)
> (In reply to comment #0)
> > I did downgrade to telepathy-gabble-0.16, telepathy-mission-control-5.12,
> > telepathy-glib-0.18 and the issue was gone.
> 
> You must have been using an outdated version of telepathy-mission-control
> from the 5.12 branch - 5.12.3 has the same code for this as 5.14.x. I think
> the same change ought to work on that branch too.

Indeed: telepathy-mission-control-5.12.1 We did froze the repo at one point and did not pull in an update it looks like.

I will try your change and report back.
Comment 5 Simon McVittie 2013-01-16 17:22:35 UTC
Created attachment 73160 [details] [review]
proposed patch for 5.12.x

Subject: Only ignore passwords in gnome-keyring if Empathy has copied them

When passwords are stored in the Parameters by MC and no
SASLAuthentication handler is used, e.g. under Sugar, we currently
save passwords into gnome-keyring, if enabled at compile time; so, we
want to read them back out of gnome-keyring.

This conflicts slightly with wanting to ignore passwords in gnome-keyring
that are left over from an Empathy 3.0 schema migration that failed
due to fd.o #42088. To avoid failure to authenticate/re-prompt if the
password has been changed on the service side, ignore passwords that
are going to be deleted; but to avoid breaking Sugar, don't ignore
any other passwords we might find in gnome-keyring.

---

This passes regression tests in the 5.12 branch. It should merge nicely into 5.14 and master, but I haven't tried that yet.
Comment 6 Simon Schampijer 2013-01-16 20:45:28 UTC
Awesome, just tested with 5.14 and things worked out fine for me. Thanks for acting on it so quickly!
Comment 7 Simon Schampijer 2013-01-17 09:36:56 UTC
Just had another positive feedback with the 5.14 fix from another colleague with a school server.

Do you guys plan a bug fix release soon? Otherwise I could add the patch to the Fedora 18 rpms in the meantime so Sugar is covered there.
Comment 8 Simon McVittie 2013-01-17 13:04:20 UTC
Also confirmed to pass tests on 5.14 here; code review required before it can be merged.
Comment 9 Daniel Drake 2013-01-24 20:20:36 UTC
Thanks for being responsive to us here. Who can we pester for a code review so that this goes upstream? :)
Comment 10 Simon Schampijer 2013-02-13 10:15:36 UTC
We have got four independent positive test results. And the code as I can judge it looks good to me. Who can help us with the final review so we can get that fix finally in? Would be great to cross this one from the 'open' list :) Thanks in advance.
Comment 11 Simon Schampijer 2013-03-14 15:50:15 UTC
Ping, I guess this did not find it's way in yet?
Comment 12 Simon McVittie 2013-04-30 11:02:24 UTC
Cc other Telepathy reviewers; any chance of some review here? I'd review it myself, but, er, I wrote it...

Since we've had several positive test results, I'll merge it anyway at some point, if nobody vetoes it.
Comment 13 Will Thompson 2013-05-01 17:06:35 UTC
Comment on attachment 73160 [details] [review]
proposed patch for 5.12.x

Review of attachment 73160 [details] [review]:
-----------------------------------------------------------------

Looks good to me.
Comment 14 Simon McVittie 2013-05-01 19:04:22 UTC
Fixed in git for 5.12.4, 5.14.1 and 5.15.0. I'll try to get some releases out later this week; it's about time we had a 5.15.0.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.