Blame SOURCES/Properly-initialize-ccaches-before-storing-into-them.patch

472fdf
From 2d91093925c8546d68f9314546353226b4f41569 Mon Sep 17 00:00:00 2001
472fdf
From: Robbie Harwood <rharwood@redhat.com>
472fdf
Date: Tue, 5 Dec 2017 13:14:29 -0500
472fdf
Subject: [PATCH] Properly initialize ccaches before storing into them
472fdf
472fdf
krb5_cc_new_unique() doesn't initialize ccaches, which results in the
472fdf
krb5 libraries being aware of their presence within the collection but
472fdf
being unable to manipulate them.
472fdf
472fdf
This is transparent to most gssproxy consumers because we just
472fdf
re-fetch the ccache on error.
472fdf
472fdf
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
472fdf
Reviewed-by: Simo Sorce <simo@redhat.com>
472fdf
Merges: #223
472fdf
(cherry picked from commit be7df45b6a56631033de387d28a2c06b7658c36a)
472fdf
---
472fdf
 proxy/src/mechglue/gpp_creds.c | 7 +++++++
472fdf
 1 file changed, 7 insertions(+)
472fdf
472fdf
diff --git a/proxy/src/mechglue/gpp_creds.c b/proxy/src/mechglue/gpp_creds.c
472fdf
index 187ada7..f8ab320 100644
472fdf
--- a/proxy/src/mechglue/gpp_creds.c
472fdf
+++ b/proxy/src/mechglue/gpp_creds.c
472fdf
@@ -247,6 +247,13 @@ uint32_t gpp_store_remote_creds(uint32_t *min, bool store_as_default_cred,
472fdf
 
472fdf
         ret = krb5_cc_new_unique(ctx, cc_type, NULL, &ccache);
472fdf
         free(cc_type);
472fdf
+        if (ret)
472fdf
+            goto done;
472fdf
+
472fdf
+        /* krb5_cc_new_unique() doesn't initialize, and we need to initialize
472fdf
+         * before storing into the ccache.  Note that this will only clobber
472fdf
+         * the ccache handle, not the whole collection. */
472fdf
+        ret = krb5_cc_initialize(ctx, ccache, cred.client);
472fdf
     }
472fdf
     if (ret)
472fdf
         goto done;