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 707402 - Support libkrb5's new kernel keyring based credentials cache
Support libkrb5's new kernel keyring based credentials cache
Status: RESOLVED FIXED
Product: gnome-online-accounts
Classification: Core
Component: Kerberos
unspecified
Other All
: Normal enhancement
: ---
Assigned To: GNOME Online Accounts maintainer(s)
GNOME Online Accounts maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-09-03 16:36 UTC by Debarshi Ray
Modified: 2013-10-14 18:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
goaidentity: fall back to polling when monitoring is unavailable (11.76 KB, patch)
2013-09-06 15:51 UTC, Ray Strode [halfline]
reviewed Details | Review
goaidentity: fall back to polling when monitoring is unavailable (14.45 KB, patch)
2013-09-06 16:04 UTC, Ray Strode [halfline]
needs-work Details | Review
goaidentity: fall back to polling when monitoring is unavailable (12.51 KB, patch)
2013-10-11 14:31 UTC, Ray Strode [halfline]
committed Details | Review
goaidentity: drop dead code (12.81 KB, patch)
2013-10-11 14:49 UTC, Ray Strode [halfline]
none Details | Review
goaidentity: drop dead code (15.00 KB, patch)
2013-10-11 14:55 UTC, Ray Strode [halfline]
committed Details | Review

Description Debarshi Ray 2013-09-03 16:36:39 UTC
A new, kernel-keyring based credential cache is being added to libkrb5. We should add support for it.
Comment 1 Ray Strode [halfline] 2013-09-06 15:51:08 UTC
Created attachment 254263 [details] [review]
goaidentity: fall back to polling when monitoring is unavailable

We don't support getting change notification for all kerberos credential
cache types.  Rather than fail, in these cases, fall back to polling.

This futureproofs the code and gives more robustness in the case of
problems.
Comment 2 Ray Strode [halfline] 2013-09-06 15:51:49 UTC
above is untested, but the idea is to mop up the general case, and then also add a non-polling variant for kernel keyring when it gains an api we can use.
Comment 3 Ray Strode [halfline] 2013-09-06 15:54:14 UTC
(for clarity, i'm saying the kernel keyring patch will come later when there's an API to use)
Comment 4 Colin Walters 2013-09-06 15:55:11 UTC
Review of attachment 254263 [details] [review]:

::: src/goaidentity/goakerberosidentitymanager.c
@@ +1398,3 @@
     cache_path++;
 
   file = g_file_new_for_path (cache_path);

We're still creating a file for the cache, which will probably work since we just end up unreffing it, but it's still a bit ugly.

@@ +1425,3 @@
     {
+      goa_warning ("GoaKerberosIdentityManager: Could not monitor credentials for %s, reverting to polling: %s",
+                   cache_path, error->message);

"monitoring_error" right?

@@ +1426,3 @@
+      goa_warning ("GoaKerberosIdentityManager: Could not monitor credentials for %s, reverting to polling: %s",
+                   cache_path, error->message);
+      g_error_free (monitoring_error);

I always use g_clear_error so that if later code is added it won't be trying to overwrite a set but freed error.

@@ +1439,3 @@
 
+  if (require_polling)
+    self->priv->polling_timeout_id = g_timeout_add_seconds (5, (GSourceFunc) on_polling_timeout, self);

A #define at top instead of 5 is possibly nicer.
Comment 5 Ray Strode [halfline] 2013-09-06 16:04:05 UTC
Created attachment 254269 [details] [review]
goaidentity: fall back to polling when monitoring is unavailable

We don't support getting change notification for all kerberos credential
cache types.  Rather than fail, in these cases, fall back to polling.

This futureproofs the code and gives more robustness in the case of
problems.
Comment 6 Ray Strode [halfline] 2013-09-06 16:05:24 UTC
thanks, all good comments.  attachment 254269 [details] [review] tries to address them, but it still needs to get testing.
Comment 7 Ray Strode [halfline] 2013-09-06 16:07:50 UTC
Review of attachment 254269 [details] [review]:

::: src/goaidentity/goakerberosidentitymanager.c
@@ +1430,3 @@
+      goa_warning ("GoaKerberosIdentityManager: Could not monitor credentials for %s, reverting to polling: %s",
+                   cache_path, monitoring_error->message);
+      g_clear_error (monitoring_error);

^ missing amperstand
Comment 8 Debarshi Ray 2013-10-11 14:02:55 UTC
Review of attachment 254269 [details] [review]:

::: src/goaidentity/goakerberosidentitymanager.c
@@ +1346,3 @@
   GFileMonitor *monitor;
   krb5_error_code error_code;
   GError *monitoring_error;

I think monitor and monitoring_error should be initialized to NULL. See below.

@@ +1429,3 @@
     {
+      goa_warning ("GoaKerberosIdentityManager: Could not monitor credentials for %s, reverting to polling: %s",
+                   cache_path, monitoring_error->message);

If we are here due to can_monitor being set to FALSE because the cache_type was neither "FILE" nor "DIR", then both monitor and monitoring_error are pointing to something undefined.

I think they should be initialized to NULL, and the goa_warning / g_clear_error should be enclosed in a "if (monitoring_error != NULL)"

@@ +1456,3 @@
+
+      g_object_unref (self->priv->credentials_cache_monitor);
+      self->priv->credentials_cache_monitor = NULL;

Could use  g_clear_object instead.
Comment 9 Ray Strode [halfline] 2013-10-11 14:31:02 UTC
Created attachment 257004 [details] [review]
goaidentity: fall back to polling when monitoring is unavailable

We don't support getting change notification for all kerberos credential
cache types.  Rather than fail, in these cases, fall back to polling.

This futureproofs the code and gives more robustness in the case of
problems.
Comment 10 Ray Strode [halfline] 2013-10-11 14:31:40 UTC
(still untested on my end, though I did run "make" this time)
Comment 11 Ray Strode [halfline] 2013-10-11 14:48:37 UTC
one thing rishi and I noticed when talking on IRC is that there's still some code that assumes the credential cache resides on the filesystem.  We don't need that code anymore so we can just drop it.
Comment 12 Ray Strode [halfline] 2013-10-11 14:49:01 UTC
Created attachment 257005 [details] [review]
goaidentity: drop dead code

We used to have to get the "raw credentials" from the kerberos
credential cache for realmd to use.  We no longer need that
so drop that code.
Comment 13 Ray Strode [halfline] 2013-10-11 14:55:35 UTC
Created attachment 257006 [details] [review]
goaidentity: drop dead code

We used to have to get the "raw credentials" from the kerberos
credential cache for realmd to use.  We no longer need that
so drop that code.
Comment 14 Ray Strode [halfline] 2013-10-11 23:21:11 UTC
So I've tested these patches locally now and they seem to work.

I did run into two problems when testing, but they're unrelated.  see bug 709953 and bug 709953 for details.
Comment 15 Debarshi Ray 2013-10-14 16:05:39 UTC
Review of attachment 257006 [details] [review]:

Sure.
Comment 16 Debarshi Ray 2013-10-14 16:13:29 UTC
Review of attachment 257004 [details] [review]:

Mostly looks good and works as expected.

::: src/goaidentity/goakerberosidentitymanager.c
@@ +1431,3 @@
+                   cache_path,
+                   cache_type,
+                   monitoring_error != NULL? monitoring_error->message : "");

You might want to use a "if (monitoring_error != NULL)" to only print a warning if there was an error. In those cases where "monitoring_error == NULL" we knowingly chose to poll because the cache_type was neither FILE nor DIR and we have already printed a warning when that happened.