diff options
| author | John Kohl <jtkohl@mit.edu> | 1990-05-01 17:12:17 +0000 |
|---|---|---|
| committer | John Kohl <jtkohl@mit.edu> | 1990-05-01 17:12:17 +0000 |
| commit | ec3674c19a8318117b3587b813f6a10dfdc0a10b (patch) | |
| tree | cdc15c051730693f6d8ea43a45a1be9af614e0aa | |
| parent | 928d268dd1ea9ddbe3eb2eeffc5500c773d3b536 (diff) | |
| download | krb5-ec3674c19a8318117b3587b813f6a10dfdc0a10b.tar.gz krb5-ec3674c19a8318117b3587b813f6a10dfdc0a10b.tar.xz krb5-ec3674c19a8318117b3587b813f6a10dfdc0a10b.zip | |
working, but braindead, version
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@656 dc483132-0cff-0310-8789-dd5450dbe970
| -rw-r--r-- | src/clients/klist/klist.c | 62 |
1 files changed, 61 insertions, 1 deletions
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 <krb5/copyright.h> #include <krb5/krb5.h> +#include <krb5/krb5_err.h> +#include <krb5/isode_err.h> +#include <krb5/ext-proto.h> +#include <com_err.h> 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); + } } |
