commit bfdc0955657ba83940c63d1d9771b09edc0cb453
Author: Nalin Dahyabhai <nalin@dahyabhai.net>
Date: Thu Dec 5 13:54:09 2013 -0500
Flag no-such-keyring errors in get/set-flags ccops
When attempting to use a keyring cache that doesn't exist, return
KRB5_FCC_NOFILE errors during ccache get/set flags ops, and set an error
message when we fail to read a principal name, bringing us more in line
with the behavior we already have when using file-based caches.
diff --git a/src/lib/krb5/ccache/cc_keyring.c b/src/lib/krb5/ccache/cc_keyring.c
index 1a0f1df..421b228 100644
--- a/src/lib/krb5/ccache/cc_keyring.c
+++ b/src/lib/krb5/ccache/cc_keyring.c
@@ -1521,16 +1521,34 @@ krb5_krcc_remove_cred(krb5_context context, krb5_ccache cache,
static krb5_error_code KRB5_CALLCONV
krb5_krcc_set_flags(krb5_context context, krb5_ccache id, krb5_flags flags)
{
+ krb5_krcc_data *d = (krb5_krcc_data *) id->data;
+
DEBUG_PRINT(("krb5_krcc_set_flags: entered\n"));
+ k5_cc_mutex_lock(context, &d->lock);
+ if (!d->cache_id) {
+ k5_cc_mutex_unlock(context, &d->lock);
+ return KRB5_FCC_NOFILE;
+ }
+ k5_cc_mutex_unlock(context, &d->lock);
+
return KRB5_OK;
}
static krb5_error_code KRB5_CALLCONV
krb5_krcc_get_flags(krb5_context context, krb5_ccache id, krb5_flags * flags)
{
+ krb5_krcc_data *d = (krb5_krcc_data *) id->data;
+
DEBUG_PRINT(("krb5_krcc_get_flags: entered\n"));
+ k5_cc_mutex_lock(context, &d->lock);
+ if (!d->cache_id) {
+ k5_cc_mutex_unlock(context, &d->lock);
+ return KRB5_FCC_NOFILE;
+ }
+ k5_cc_mutex_unlock(context, &d->lock);
+
*flags = 0;
return KRB5_OK;
}
@@ -1707,6 +1725,12 @@ krb5_krcc_retrieve_principal(krb5_context context, krb5_ccache id,
if (!d->cache_id || !d->princ_id) {
princ = 0L;
kret = KRB5_FCC_NOFILE;
+ if (d->name) {
+ krb5_set_error_message(context, kret,
+ _("Credentials cache keyring '%s' "
+ "not found"),
+ d->name);
+ }
goto errout;
}