>From c3367a9e7f0f9a795cc6d1d55ed979ddc0ed0ef3 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Wed, 29 May 2013 09:57:38 +0200 Subject: [PATCH 2/2] Every time return directory for krb5 cache collection. Function krb5_cc_get_full_name is called only as a way to validate that, we have the right cache. Instead of returned name, location will be returned from function cc_dir_cache_for_princ. https://fedorahosted.org/sssd/ticket/1936 --- src/providers/krb5/krb5_child.c | 8 ++++++++ src/providers/krb5/krb5_utils.c | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c index 4626f59ff48fada92e1b38033dfc910c181af7c4..2bf67567ccb95f7a102dfb2279f2795856ce27c3 100644 --- a/src/providers/krb5/krb5_child.c +++ b/src/providers/krb5/krb5_child.c @@ -692,6 +692,14 @@ create_ccache_in_dir(uid_t uid, gid_t gid, goto done; } + kerr = krb5_cc_cache_match(ctx, princ, &tmp_cc); + if (kerr == 0) { + /* We have found existing ccache in collection cache directory. + * It is not needed to create new cache or to store cache. + */ + goto done; + } + kerr = krb5_cc_new_unique(ctx, "DIR", NULL, &tmp_cc); if (kerr != 0) { KRB5_CHILD_DEBUG(SSSDBG_OP_FAILURE, kerr); diff --git a/src/providers/krb5/krb5_utils.c b/src/providers/krb5/krb5_utils.c index 1883d785e6746c45e51c8b0fabe01afbad688d6d..3f16faa7fb238bbb9801029beed66293cd873c15 100644 --- a/src/providers/krb5/krb5_utils.c +++ b/src/providers/krb5/krb5_utils.c @@ -1164,6 +1164,9 @@ cc_dir_cache_for_princ(TALLOC_CTX *mem_ctx, const char *location, return NULL; } + /* This function is called only as a way to validate that, + * we have the right cache + */ krberr = krb5_cc_get_full_name(context, ccache, &name); if (ccache) krb5_cc_close(context, ccache); krb5_free_context(context); @@ -1173,7 +1176,7 @@ cc_dir_cache_for_princ(TALLOC_CTX *mem_ctx, const char *location, return NULL; } - return talloc_strdup(mem_ctx, name); + return talloc_strdup(mem_ctx, location); } errno_t -- 1.8.1.4