/* * Display all ccaches in a collection, in short form. */ int do_collection() { #ifdef HAVE_KRB5_COLLECTIONS krb5_error_code retval; krb5_cccol_cursor cursor; krb5_ccache cache; #endif if (!show_ccname_only && !show_names_only && !show_defname_only) { printf("default\t%s\n", krb5_cc_default_name(ctx)); printf("COLLECTION\tccname\tprincipal\n"); } #ifdef HAVE_KRB5_COLLECTIONS if ((retval = krb5_cccol_cursor_new(ctx, &cursor))) { com_err(progname, retval, "while listing ccache collection"); exit(1); } while (!(retval = krb5_cccol_cursor_next(ctx, cursor, &cache))) { if (cache == NULL) break; do_ccache(cache); krb5_cc_close(ctx, cache); } krb5_cccol_cursor_free(ctx, &cursor); return 0; #else return do_ccache_by_name(NULL); #endif }
// // Returns 0 for success, 1 for failure // int do_all_ccaches(krb5_context ctx, TICKETINFO **ticketinfotail) { krb5_error_code code; krb5_ccache cache; krb5_cccol_cursor cursor; int retval = 0; char *functionName = NULL; code = pkrb5_cccol_cursor_new(ctx, &cursor); if (code) { functionName = "krb5_cccol_cursor_new"; goto cleanup; } retval = 0; while (!(code = pkrb5_cccol_cursor_next(ctx, cursor, &cache)) && cache != NULL) { // Note that ticketList will be updated here to point to the tail // of the list but the caller of this function will remain with a // pointer to the head. do_ccache(ctx, cache, &ticketinfotail); pkrb5_cc_close(ctx, cache); } if (code) functionName = "krb5_cccol_cursor_next"; pkrb5_cccol_cursor_free(ctx, &cursor); cleanup: if (code) { Leash_krb5_error(code, functionName, 0, NULL, NULL); } return retval; }
/* * resolve a ccache and output its contents */ int do_ccache_by_name(char *name) { krb5_ccache cache; int status = 1; cache = resolve_ccache(name); if (cache) { status = do_ccache(cache); krb5_cc_close(ctx, cache); } return status; }