Blame SOURCES/Only-empty-FILE-ccaches-when-storing-remote-creds.patch

8c527e
From 1fa33903be640f8d22757d21da294e70f0812698 Mon Sep 17 00:00:00 2001
c530df
From: Robbie Harwood <rharwood@redhat.com>
c530df
Date: Tue, 10 Oct 2017 18:00:45 -0400
c530df
Subject: [PATCH] Only empty FILE ccaches when storing remote creds
c530df
c530df
This mitigates issues when services share a ccache between two
c530df
processes.  We cannot fix this for FILE ccaches without introducing
c530df
other issues.
c530df
c530df
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
c530df
Reviewed-by: Simo Sorce <simo@redhat.com>
c530df
Merges: #216
c530df
(cherry picked from commit d09e87f47a21dd250bfd7a9c59a5932b5c995057)
c530df
---
c530df
 proxy/src/mechglue/gpp_creds.c | 18 +++++++++++++-----
c530df
 1 file changed, 13 insertions(+), 5 deletions(-)
c530df
c530df
diff --git a/proxy/src/mechglue/gpp_creds.c b/proxy/src/mechglue/gpp_creds.c
c530df
index 9fe9bd1..6bdff45 100644
c530df
--- a/proxy/src/mechglue/gpp_creds.c
c530df
+++ b/proxy/src/mechglue/gpp_creds.c
c530df
@@ -147,6 +147,7 @@ uint32_t gpp_store_remote_creds(uint32_t *min, bool default_creds,
c530df
     char cred_name[creds->desired_name.display_name.octet_string_len + 1];
c530df
     XDR xdrctx;
c530df
     bool xdrok;
c530df
+    const char *cc_type;
c530df
 
c530df
     *min = 0;
c530df
 
c530df
@@ -193,13 +194,20 @@ uint32_t gpp_store_remote_creds(uint32_t *min, bool default_creds,
c530df
     }
c530df
     cred.ticket.length = xdr_getpos(&xdrctx);
c530df
 
c530df
-    /* Always initialize and destroy any existing contents to avoid pileup of
c530df
-     * entries */
c530df
-    ret = krb5_cc_initialize(ctx, ccache, cred.client);
c530df
-    if (ret == 0) {
c530df
-        ret = krb5_cc_store_cred(ctx, ccache, &cred);
c530df
+    cc_type = krb5_cc_get_type(ctx, ccache);
c530df
+    if (strcmp(cc_type, "FILE") == 0) {
c530df
+        /* FILE ccaches don't handle updates properly: if they have the same
c530df
+         * principal name, they are blackholed.  We either have to change the
c530df
+         * name (at which point the file grows forever) or flash the cache on
c530df
+         * every update. */
c530df
+        ret = krb5_cc_initialize(ctx, ccache, cred.client);
c530df
+        if (ret != 0) {
c530df
+            goto done;
c530df
+        }
c530df
     }
c530df
 
c530df
+    ret = krb5_cc_store_cred(ctx, ccache, &cred);
c530df
+
c530df
 done:
c530df
     if (ctx) {
c530df
         krb5_free_cred_contents(ctx, &cred);