From: Marc Horowitz Date: Sat, 22 Aug 1998 02:28:40 +0000 (+0000) Subject: add -a and -n arguments for printing ticket addresses X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7c7ddf81728a320f28ce76f4119ed50850a27b9;p=thirdparty%2Fkrb5.git add -a and -n arguments for printing ticket addresses git-svn-id: svn://anonsvn.mit.edu/krb5/branches/marc-3des@10865 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/clients/klist/klist.c b/src/clients/klist/klist.c index 005c057603..671316b2c8 100644 --- a/src/clients/klist/klist.c +++ b/src/clients/klist/klist.c @@ -30,11 +30,13 @@ #include #include #include +#include +#include extern int optind; extern char *optarg; int show_flags = 0, show_time = 0, status_only = 0, show_keys = 0; -int show_etype = 0; +int show_etype = 0, show_addresses = 0, no_resolve = 0; char *defname; char *progname; krb5_int32 now; @@ -50,6 +52,7 @@ void show_credential KRB5_PROTOTYPE((char *, void do_ccache KRB5_PROTOTYPE((char *)); void do_keytab KRB5_PROTOTYPE((char *)); void printtime KRB5_PROTOTYPE((time_t)); +void one_addr KRB5_PROTOTYPE((krb5_address *)); void fillit KRB5_PROTOTYPE((FILE *, int, int)); #define DEFAULT 0 @@ -58,7 +61,7 @@ void fillit KRB5_PROTOTYPE((FILE *, int, int)); void usage() { - fprintf(stderr, "Usage: %s [[-c] [-f] [-e] [-s]] [-k [-t] [-K]] [name]\n", + fprintf(stderr, "Usage: %s [[-c] [-f] [-e] [-s] [-a] [-n]] [-k [-t] [-K]] [name]\n", progname); fprintf(stderr, "\t-c specifies credentials cache, -k specifies keytab"); fprintf(stderr, ", -c is default\n"); @@ -66,6 +69,8 @@ void usage() fprintf(stderr, "\t\t-f shows credentials flags\n"); fprintf(stderr, "\t\t-e shows the encryption type\n"); fprintf(stderr, "\t\t-s sets exit status based on valid tgt existence\n"); + fprintf(stderr, "\t\t-a displays the address list\n"); + fprintf(stderr, "\t\t\t-n do not reverse-resolve\n"); fprintf(stderr, "\toptions for keytabs:\n"); fprintf(stderr, "\t\t-t shows keytab entry timestamps\n"); fprintf(stderr, "\t\t-K shows keytab entry DES keys\n"); @@ -114,6 +119,12 @@ main(argc, argv) case 's': status_only = 1; break; + case 'n': + no_resolve = 1; + break; + case 'a': + show_addresses = 1; + break; case 'c': if (mode != DEFAULT) usage(); mode = CCACHE; @@ -498,10 +509,52 @@ show_credential(progname, kcontext, cred) /* if any additional info was printed, extra_field is non-zero */ if (extra_field) putchar('\n'); + + + if (show_addresses) { + if (!cred->addresses || !cred->addresses[0]) { + printf("\tAddresses: (none)\n"); + } else { + int i; + + printf("\tAddresses: "); + one_addr(cred->addresses[0]); + + for (i=1; cred->addresses[i]; i++) { + printf(", "); + one_addr(cred->addresses[1]); + } + + printf("\n"); + } + } + free(name); free(sname); } +void one_addr(a) + krb5_address *a; +{ + struct hostent *h; + + if ((a->addrtype == ADDRTYPE_INET) && + (a->length == 4)) { + if (!no_resolve) { + h = gethostbyaddr(a->contents, 4, AF_INET); + if (h) { + printf("%s", h->h_name); + } + } + if (no_resolve || !h) { + printf("%d.%d.%d.%d", a->contents[0], a->contents[1], + a->contents[2], a->contents[3]); + } + } else { + printf("unknown addr type %d", a->addrtype); + } +} + void fillit(f, num, c) FILE *f;