diff options
author | Greg Hudson <ghudson@mit.edu> | 2011-09-05 16:26:48 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2011-09-05 16:26:48 +0000 |
commit | 916555623ea3c0cd8976718f0b989280df9260ce (patch) | |
tree | b93331f1e121874fae9e6e31eabe9c46f0ce10a4 /src/clients/kdestroy | |
parent | 45360c9688ca963f75a2480f2cf818424fc3dc7b (diff) | |
download | krb5-916555623ea3c0cd8976718f0b989280df9260ce.tar.gz krb5-916555623ea3c0cd8976718f0b989280df9260ce.tar.xz krb5-916555623ea3c0cd8976718f0b989280df9260ce.zip |
Add ccache collection support to tools
* "kdestroy -A" destroys all caches in collection.
* "kinit princ" searches the collection for a matching cache and
overwrites it, or creates a new cache in the collection, if the
type of the default cache is collection-enabled. The chosen cache
also becomes the primary cache for the collection.
* "klist -l" lists (in summary form) the caches in the collection.
* "klist -A" lists the content of all of the caches in the collection.
* "kswitch -c cache" (new command) makes cache the primary cache.
* "kswitch -p princ" makes the cache for princ the primary cache.
ticket: 6956
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25157 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/clients/kdestroy')
-rw-r--r-- | src/clients/kdestroy/kdestroy.M | 12 | ||||
-rw-r--r-- | src/clients/kdestroy/kdestroy.c | 34 |
2 files changed, 42 insertions, 4 deletions
diff --git a/src/clients/kdestroy/kdestroy.M b/src/clients/kdestroy/kdestroy.M index ada2ae3dcf..4deaa5fde2 100644 --- a/src/clients/kdestroy/kdestroy.M +++ b/src/clients/kdestroy/kdestroy.M @@ -26,7 +26,7 @@ kdestroy \- destroy Kerberos tickets .SH SYNOPSIS .B kdestroy -[\fB\-q\fP] [\fB\-c\fP \fIcache_name] +[\fB\-A\fP] [\fB\-q\fP] [\fB\-c\fP \fIcache_name] .br .SH DESCRIPTION The @@ -37,6 +37,9 @@ the credentials cache is not specified, the default credentials cache is destroyed. .SH OPTIONS .TP +.B \-A +Destroys all caches in the collection, if a cache collection is +available. .B \-q Run quietly. Normally .B kdestroy @@ -65,7 +68,12 @@ file, so that your tickets are destroyed automatically when you log out. uses the following environment variables: .TP "\w'.SM KRB5CCNAME\ \ 'u" .SM KRB5CCNAME -Location of the Kerberos 5 credentials (ticket) cache. +Location of the default Kerberos 5 credentials (ticket) cache, in the +form \fItype\fP:\fIresidual\fP. If no type prefix is present, the +\fBFILE\fP type is assumed. The type of the default cache may +determine the availability of a cache collection; for instance, a +default cache of type \fBDIR\fP causes caches within the directory to +be present in the collection. .SH FILES .TP "\w'/tmp/krb5cc_[uid]\ \ 'u" /tmp/krb5cc_[uid] diff --git a/src/clients/kdestroy/kdestroy.c b/src/clients/kdestroy/kdestroy.c index 73ce04459b..abe49533d4 100644 --- a/src/clients/kdestroy/kdestroy.c +++ b/src/clients/kdestroy/kdestroy.c @@ -55,7 +55,8 @@ static void usage() { #define KRB_AVAIL_STRING(x) ((x)?"available":"not available") - fprintf(stderr, _("Usage: %s [-q] [-c cache_name]\n"), progname); + fprintf(stderr, _("Usage: %s [-A] [-q] [-c cache_name]\n"), progname); + fprintf(stderr, _("\t-A destroy all credential caches in collection\n")); fprintf(stderr, _("\t-q quiet mode\n")); fprintf(stderr, _("\t-c specify name of credentials cache\n")); exit(2); @@ -70,16 +71,21 @@ main(argc, argv) krb5_error_code retval; int c; krb5_ccache cache = NULL; + krb5_cccol_cursor cursor; char *cache_name = NULL; int code = 0; int errflg = 0; int quiet = 0; + int all = 0; setlocale(LC_MESSAGES, ""); progname = GET_PROGNAME(argv[0]); - while ((c = getopt(argc, argv, "54qc:")) != -1) { + while ((c = getopt(argc, argv, "54Aqc:")) != -1) { switch (c) { + case 'A': + all = 1; + break; case 'q': quiet = 1; break; @@ -117,6 +123,30 @@ main(argc, argv) exit(1); } + if (all) { + code = krb5_cccol_cursor_new(kcontext, &cursor); + if (code) { + com_err(progname, code, _("while listing credential caches")); + exit(1); + } + while ((code = krb5_cccol_cursor_next(kcontext, cursor, + &cache)) == 0 && cache != NULL) { + code = krb5_cc_get_full_name(kcontext, cache, &cache_name); + if (code) { + com_err(progname, code, _("composing ccache name")); + exit(1); + } + code = krb5_cc_destroy(kcontext, cache); + if (code && code != KRB5_FCC_NOFILE) { + com_err(progname, code, _("while destroying cache %s"), + cache_name); + } + krb5_free_string(kcontext, cache_name); + } + krb5_cccol_cursor_free(kcontext, &cursor); + return 0; + } + if (cache_name) { code = krb5_cc_resolve (kcontext, cache_name, &cache); if (code != 0) { |