From ec3674c19a8318117b3587b813f6a10dfdc0a10b Mon Sep 17 00:00:00 2001 From: John Kohl Date: Tue, 1 May 1990 17:12:17 +0000 Subject: [PATCH] working, but braindead, version git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@656 dc483132-0cff-0310-8789-dd5450dbe970 --- src/clients/klist/klist.c | 62 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/clients/klist/klist.c b/src/clients/klist/klist.c index 0e96b3554..fdbc7879f 100644 --- a/src/clients/klist/klist.c +++ b/src/clients/klist/klist.c @@ -19,23 +19,36 @@ static char rcsid_klist_c [] = #include #include +#include +#include +#include +#include extern int optind; extern char *optarg; +void main(argc, argv) int argc; char **argv; { int c; - int i; int errflg = 0; int code; krb5_ccache cache = NULL; krb5_cc_cursor cur; + krb5_creds creds; char *cache_name; + krb5_principal princ; + char *name, *sname; + krb5_flags flags; initialize_krb5_error_table(); + initialize_isod_error_table(); + + + if (rindex(argv[0], '/')) + argv[0] = rindex(argv[0], '/')+1; while ((c = getopt(argc, argv, "c:")) != EOF) { switch (c) { @@ -67,4 +80,51 @@ main(argc, argv) fprintf(stderr, "Usage: %s [ -c cache ]\n", argv[0]); exit(2); } + if (cache == NULL) + cache = krb5_cc_default(); + + flags = 0; /* turns off OPENCLOSE mode */ + if (code = (*cache->ops->set_flags)(cache, flags)) { + com_err(argv[0], code, "while setting cache flags"); + exit(1); + } + if (code = (*cache->ops->get_princ)(cache, &princ)) { + com_err(argv[0], code, "while retrieving principal name"); + exit(1); + } + if (code = krb5_unparse_name(princ, &name)) { + com_err(argv[0], code, "while unparsing principal name"); + exit(1); + } + printf("Ticket cache: %s\nDefault principal: %s\n", + (*cache->ops->get_name)(cache), name); + free(name); + if (code = (*cache->ops->get_first)(cache, &cur)) { + com_err(argv[0], code, "while starting to retrieve tickets"); + exit(1); + } + while (!(code = (*cache->ops->get_next)(cache, &cur, &creds))) { + code = krb5_unparse_name(creds.client, &name); + if (code) { + com_err(argv[0], code, "while unparsing client name"); + continue; + } + code = krb5_unparse_name(creds.server, &sname); + if (code) { + com_err(argv[0], code, "while unparsing server name"); + free(name); + continue; + } + printf("C: %s\tS:%s\n", name, sname); + } + if (code == KRB5_CC_END) { + if (code = (*cache->ops->end_get)(cache, &cur)) { + com_err(argv[0], code, "while finishing ticket retrieval"); + exit(1); + } + exit(0); + } else { + com_err(argv[0], code, "while retrieving a ticket"); + exit(1); + } } -- 2.26.2