Skip to content

Commit 08d7a13

Browse files
Only empty FILE ccaches when storing remote creds
This mitigates issues when services share a ccache between two processes. We cannot fix this for FILE ccaches without introducing other issues. Signed-off-by: Robbie Harwood <[email protected]> Reviewed-by: Simo Sorce <[email protected]> Merges: #216
1 parent 36cca8d commit 08d7a13

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/mechglue/gpp_creds.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ uint32_t gpp_store_remote_creds(uint32_t *min, bool default_creds,
147147
char cred_name[creds->desired_name.display_name.octet_string_len + 1];
148148
XDR xdrctx;
149149
bool xdrok;
150+
const char *cc_type;
150151

151152
*min = 0;
152153

@@ -193,13 +194,20 @@ uint32_t gpp_store_remote_creds(uint32_t *min, bool default_creds,
193194
}
194195
cred.ticket.length = xdr_getpos(&xdrctx);
195196

196-
/* Always initialize and destroy any existing contents to avoid pileup of
197-
* entries */
198-
ret = krb5_cc_initialize(ctx, ccache, cred.client);
199-
if (ret == 0) {
200-
ret = krb5_cc_store_cred(ctx, ccache, &cred);
197+
cc_type = krb5_cc_get_type(ctx, ccache);
198+
if (strcmp(cc_type, "FILE") == 0) {
199+
/* FILE ccaches don't handle updates properly: if they have the same
200+
* principal name, they are blackholed. We either have to change the
201+
* name (at which point the file grows forever) or flash the cache on
202+
* every update. */
203+
ret = krb5_cc_initialize(ctx, ccache, cred.client);
204+
if (ret != 0) {
205+
goto done;
206+
}
201207
}
202208

209+
ret = krb5_cc_store_cred(ctx, ccache, &cred);
210+
203211
done:
204212
if (ctx) {
205213
krb5_free_cred_contents(ctx, &cred);

0 commit comments

Comments
 (0)