From 9175e66cdb298c4197a30d38ad1ace63a976c6ec Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Wed, 4 Oct 2006 10:44:28 +0000 Subject: [PATCH] The keyring code introduced in r18638 also included tests of the KEYRING: regardless of whether the type is registered or not in the library. Test to see if KEYRING: is registered - and if so - run the tests on it. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18642 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/t_cc.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/lib/krb5/ccache/t_cc.c b/src/lib/krb5/ccache/t_cc.c index 0db618b76..247145b6c 100644 --- a/src/lib/krb5/ccache/t_cc.c +++ b/src/lib/krb5/ccache/t_cc.c @@ -207,6 +207,37 @@ static void cc_test(krb5_context context, const char *name, int flags) } +/* + * Checks if a credential type is registered with the library + */ +static int check_registered(krb5_context context, const char *prefix) +{ + + char name[300]; + krb5_error_code kret; + krb5_ccache id; + + sprintf(name, "%s/tmp/cctest.%ld", prefix, (long) getpid()); + + kret = krb5_cc_resolve(context, name, &id); + if(kret != KRB5_OK) { + if(kret == KRB5_CC_UNKNOWN_TYPE) + return 0; + com_err("Checking on credential type", kret,prefix); + fflush(stderr); + return 0; + } + + kret = krb5_cc_close(context, id); + if(kret != KRB5_OK) { + com_err("Checking on credential type - closing", kret,prefix); + fflush(stderr); + } + + return 1; +} + + static void do_test(krb5_context context, const char *prefix) { char name[300]; @@ -285,7 +316,12 @@ int main (void) test_misc(context); do_test(context, ""); - do_test(context, "KEYRING:"); + + if(check_registered(context, "KEYRING:")) + do_test(context, "KEYRING:"); + else + printf("Skiping KEYRING: test - unregistered type\n"); + do_test(context, "MEMORY:"); do_test(context, "FILE:"); -- 2.26.2