From 84bb5a92c1bc9509e978be51243165866b84e1b8 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Fri, 6 Mar 2009 23:57:10 +0000 Subject: [PATCH] Add "-V" option to klist to print the package name and version, and exit ticket: 4241 target_version: 1.7 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22068 dc483132-0cff-0310-8789-dd5450dbe970 --- src/clients/klist/klist.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/clients/klist/klist.c b/src/clients/klist/klist.c index 70ca604e5..c20aa9801 100644 --- a/src/clients/klist/klist.c +++ b/src/clients/klist/klist.c @@ -56,7 +56,7 @@ extern int optind; int show_flags = 0, show_time = 0, status_only = 0, show_keys = 0; -int show_etype = 0, show_addresses = 0, no_resolve = 0; +int show_etype = 0, show_addresses = 0, no_resolve = 0, print_version = 0; char *defname; char *progname; krb5_int32 now; @@ -81,12 +81,13 @@ static void usage() { #define KRB_AVAIL_STRING(x) ((x)?"available":"not available") - fprintf(stderr, "Usage: %s [-e] [[-c] [-f] [-s] [-a [-n]]] %s", + fprintf(stderr, "Usage: %s [-e] [-V] [[-c] [-f] [-s] [-a [-n]]] %s", progname, "[-k [-t] [-K]] [name]\n"); fprintf(stderr, "\t-c specifies credentials cache\n"); fprintf(stderr, "\t-k specifies keytab\n"); fprintf(stderr, "\t (Default is credentials cache)\n"); fprintf(stderr, "\t-e shows the encryption type\n"); + fprintf(stderr, "\t-V shows the Kerberos version and exits\n"); fprintf(stderr, "\toptions for credential caches:\n"); fprintf(stderr, "\t\t-f shows credentials flags\n"); fprintf(stderr, "\t\t-s sets exit status based on valid tgt existence\n"); @@ -111,7 +112,8 @@ main(argc, argv) name = NULL; mode = DEFAULT; - while ((c = getopt(argc, argv, "fetKsnack45")) != -1) { + /* V=version so v can be used for verbose later if desired. */ + while ((c = getopt(argc, argv, "fetKsnack45V")) != -1) { switch (c) { case 'f': show_flags = 1; @@ -148,6 +150,9 @@ main(argc, argv) break; case '5': break; + case 'V': + print_version = 1; + break; default: usage(); break; @@ -172,6 +177,11 @@ main(argc, argv) usage(); } + if (print_version) { + printf("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION); + exit(0); + } + name = (optind == argc-1) ? argv[optind] : 0; now = time(0); -- 2.26.2