After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 796095 - Kerberos tickets not refreshed on resume
Kerberos tickets not refreshed on resume
Status: RESOLVED FIXED
Product: gnome-online-accounts
Classification: Core
Component: Kerberos
3.28.x
Other Linux
: Normal normal
: ---
Assigned To: GNOME Online Accounts maintainer(s)
GNOME Online Accounts maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2018-05-14 10:18 UTC by Mantas Mikulėnas (grawity)
Modified: 2019-01-17 11:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GoaAlarm: Continue firing on ECANCELED from timerfd (1.63 KB, patch)
2018-05-14 17:05 UTC, Jan Alexander Steffens (heftig)
reviewed Details | Review
alarm: Refresh Kerberos tickets after a suspended system is resumed (1.68 KB, patch)
2018-11-23 12:37 UTC, Debarshi Ray
committed Details | Review

Description Mantas Mikulėnas (grawity) 2018-05-14 10:18:32 UTC
Whenever my PC resumes from standby on mornings, my Kerberos tickets are usually expired. I think this hasn't been working for a long time, but in 3.27/3.28 I'm at least getting error messages on resume:

    goa-identity-se[1130]: GoaAlarm: failed to read from timer fd: Error reading from file descriptor: Operation canceled

gnome-online-accounts 3.28.0
Comment 1 Jan Alexander Steffens (heftig) 2018-05-14 17:05:37 UTC
Created attachment 372033 [details] [review]
GoaAlarm: Continue firing on ECANCELED from timerfd

A read() from the timerfd will return G_IO_ERROR_CANCELLED when the clock jumps, e.g. when the
system time is set or the system wakes from suspend (see man 2 timerfd_create). In this case,
instead of giving up on firing completely, continue on to call fire_or_rearm_alarm. This should be
the right thing to do.
Comment 2 Jan Alexander Steffens (heftig) 2018-09-01 21:30:19 UTC
Please review.
Comment 3 Debarshi Ray 2018-11-21 14:16:28 UTC
Review of attachment 372033 [details] [review]:

Thanks for figuring this out, and sorry for the long delay in getting round to this.

From the looks of it, this does look like the right thing to do. I will test this across a suspend-resume cycle today before merging it.
Comment 4 Debarshi Ray 2018-11-21 14:17:14 UTC
@halfline: does this look OK to you?
Comment 5 Debarshi Ray 2018-11-22 14:43:10 UTC
I reproduced this overnight with a KCM credential cache.

After resuming from suspend I did get the "failed to read from timer fd" in my logs and my tickets were expired. However, a few minutes later I noticed that I have new tickets in my cache. I wonder if that was some trick performed by the KCM cache. Being backed by SSSD, I think it has some smarts built into it, unlike DIR, FILE or KEYRING, which are passive entities.

Right after resumption:

$ klist -A
Ticket cache: KCM:1000:14945
Default principal: rishi@FEDORAPROJECT.ORG

Valid starting       Expires              Service principal
2018-11-21T10:37:49  2018-11-22T10:37:48  krbtgt/FEDORAPROJECT.ORG@FEDORAPROJECT.ORG
	renew until 2018-11-28T10:37:49

Ticket cache: KCM:1000
Default principal: dray@REDHAT.COM

Valid starting       Expires              Service principal
2018-11-21T18:43:14  2018-11-22T04:43:14  krbtgt/REDHAT.COM@REDHAT.COM
	renew until 2018-11-28T18:43:14

A minute or two later:

$ klist -A
Ticket cache: KCM:1000:14945
Default principal: rishi@FEDORAPROJECT.ORG

Valid starting       Expires              Service principal
2018-11-22T15:31:27  2018-11-23T15:31:26  krbtgt/FEDORAPROJECT.ORG@FEDORAPROJECT.ORG
	renew until 2018-11-29T15:31:27

Ticket cache: KCM:1000
Default principal: dray@REDHAT.COM

Valid starting       Expires              Service principal
2018-11-22T15:31:28  2018-11-23T01:31:28  krbtgt/REDHAT.COM@REDHAT.COM
	renew until 2018-11-29T15:31:28
Comment 6 Debarshi Ray 2018-11-23 12:37:53 UTC
Created attachment 374161 [details] [review]
alarm: Refresh Kerberos tickets after a suspended system is resumed

Rebased against master.

I tweaked the debug message to mention "timer fd", and added the user visibile effect to the commit message.
Comment 7 Ray Strode [halfline] 2018-11-23 13:41:26 UTC
makes sense to me
Comment 8 Debarshi Ray 2018-11-23 14:13:59 UTC
Ok, thanks Ray.

The tickets on my KEYRING cache are about to expire, and I am going to test the fix on both KCM and KEYRING after that. Once that's done, I will merge it.

For context, grawity has FILE caches and heftig managed to fix this blindly without even using Kerberos (wow!). Hence my insistence on reproducing the problem and testing the fix.
Comment 9 Debarshi Ray 2018-11-23 21:03:09 UTC
KEYRING caches are also able to recover a few minutes after resumption, even though I get the "failed to read from timer fd" in my logs.

Right after resumption:

$ klist -A
$

A minute or two later:

$ klist -A
Ticket cache: KEYRING:persistent:1000:1000
Default principal: rishi@FEDORAPROJECT.ORG

Valid starting       Expires              Service principal
2018-11-23T21:52:28  2018-11-24T21:52:27  krbtgt/FEDORAPROJECT.ORG@FEDORAPROJECT.ORG
	renew until 2018-11-30T21:52:28

It might be that DIR and FILE caches are the only ones that actually fail to refresh the credentials. In that case it might be related to the fact that DIR and FILE caches notify us of changes through inotify(7) while for KEYRING and KCM we poll the cache.
Comment 10 Debarshi Ray 2019-01-17 09:52:05 UTC
It turns out that this patch does make a difference if there's a change in network across the suspend-resume cycle. eg., Tomas tested this with a KCM cache. Earlier, if he had suspended on a network where the KDC wasn't reachable and resumed on one where it was, his tickets wouldn't be refreshed, but with this patch, it works.
Comment 11 Debarshi Ray 2019-01-17 11:43:23 UTC
Pushed to master, gnome-3-30, and gnome-3-28, and rolled tarballs for the stable branches. Thanks everybody!