From: Matt Rogers Date: Tue, 26 Jan 2016 19:59:43 +0000 (-0500) Subject: Add hints for -A flag to kdestroy X-Git-Tag: krb5-1.15-beta1~157 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4cc39674b407a0d9698097b27788b3ffdbc6fca;p=thirdparty%2Fkrb5.git Add hints for -A flag to kdestroy When using a collection ccache, a user accustomed to the FILE ccache behavior may not be aware of all active caches, and the default kdestroy command could make it seem like there is no active cache left. Print a warning to use -A after kdestroy if there are other caches. ticket: 8451 (new) --- diff --git a/src/clients/kdestroy/kdestroy.c b/src/clients/kdestroy/kdestroy.c index 410d6cf4cb..214643b807 100644 --- a/src/clients/kdestroy/kdestroy.c +++ b/src/clients/kdestroy/kdestroy.c @@ -60,6 +60,30 @@ static void usage() exit(2); } +/* Print a warning if there are still un-destroyed caches in the collection. */ +static void +print_remaining_cc_warning(krb5_context context) +{ + krb5_error_code retval; + krb5_ccache cache; + krb5_cccol_cursor cursor; + + retval = krb5_cccol_cursor_new(context, &cursor); + if (retval) { + com_err(progname, retval, _("while listing credential caches")); + exit(1); + } + + retval = krb5_cccol_cursor_next(context, cursor, &cache); + if (retval == 0 && cache != NULL) { + fprintf(stderr, + _("Other credential caches present, use -A to destroy all\n")); + krb5_cc_close(context, cache); + } + + krb5_cccol_cursor_free(context, &cursor); +} + int main(argc, argv) int argc; @@ -172,5 +196,9 @@ main(argc, argv) errflg = 1; } } + + if (!quiet && !errflg) + print_remaining_cc_warning(kcontext); + return errflg; }