From a643314c55acc9ed98064b21d2f45880e456b3ba Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Mon, 13 May 2013 13:52:55 +0200 Subject: [PATCH] add -V switch to get tool version --- ykchalresp.1 | 5 ++++- ykchalresp.c | 8 +++++++- ykinfo.1 | 4 +++- ykinfo.c | 8 +++++++- ykpers-args.c | 8 +++++++- ykpersonalize.1 | 5 ++++- 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ykchalresp.1 b/ykchalresp.1 index 5cb261c..f959fc3 100644 --- a/ykchalresp.1 +++ b/ykchalresp.1 @@ -35,7 +35,7 @@ ykchalresp - Perform challenge-response operation with YubiKey .SH SYNOPSIS .B ykchalresp -[\fI-1\fR | \fI-2\fR] [\fI-H\fR] [\fI-Y\fR] [\fI-N\fR] [\fI-x\fR] [\fI-v\fR] [\fI-h\fR] +[\fI-1\fR | \fI-2\fR] [\fI-H\fR] [\fI-Y\fR] [\fI-N\fR] [\fI-x\fR] [\fI-v\fR] [\fI-V\fR] [\fI-h\fR] .SH DESCRIPTION .PP Send a challenge to a YubiKey, and read the response. The YubiKey can be configured @@ -65,6 +65,9 @@ challenge is hex encoded. .TP \fB\-v\fR enable verbose mode. +.TP +\fB\-V\fR +print tool version and exit. .SH EXAMPLE The YubiKey challenge-response operation can be demonstrated using the diff --git a/ykchalresp.c b/ykchalresp.c index 9577b36..fdeeb4b 100644 --- a/ykchalresp.c +++ b/ykchalresp.c @@ -39,6 +39,7 @@ #include #include #include +#include const char *usage = "Usage: ykchalresp [options] challenge\n" @@ -53,11 +54,12 @@ const char *usage = "\t-x Challenge is hex encoded.\n" "\n" "\t-v verbose\n" + "\t-V tool version\n" "\t-h help (this text)\n" "\n" "\n" ; -const char *optstring = "12xvhHYN"; +const char *optstring = "12xvhHYNV"; static void report_yk_error(void) { @@ -104,6 +106,10 @@ static int parse_args(int argc, char **argv, case 'v': *verbose = true; break; + case 'V': + fputs(YKPERS_VERSION_STRING "\n", stderr); + *exit_code = 0; + return 0; case 'h': default: fputs(usage, stderr); diff --git a/ykinfo.1 b/ykinfo.1 index f9804a8..dacd5b3 100644 --- a/ykinfo.1 +++ b/ykinfo.1 @@ -35,7 +35,7 @@ ykinfo - Get basic information from a YubiKey .SH SYNOPSIS .B ykinfo -[\fI-s\fR] [\fI-m\fR] [\fI-H\fR] [\fI-v\fR] [\fI-t\fR] [\fI-p\fR] [\fI-q\fR] [\fI-h\fR] +[\fI-s\fR] [\fI-m\fR] [\fI-H\fR] [\fI-v\fR] [\fI-t\fR] [\fI-p\fR] [\fI-q\fR] [\fI-V\fR] [\fI-h\fR] .SH DESCRIPTION .PP Get basic information from a YubiKey. Can get serial number, version @@ -68,6 +68,8 @@ get all the information above. \fB\-q\fR modifier, only show the relevant data from the YubiKey, no extra information. .TP +\fB\-V\fR +print tool version and exit .SH EXAMPLE Output of all information from a YubiKey diff --git a/ykinfo.c b/ykinfo.c index dc846fa..0015e7f 100644 --- a/ykinfo.c +++ b/ykinfo.c @@ -37,6 +37,7 @@ #include #include #include +#include const char *usage = "Usage: ykinfo [options]\n" @@ -53,11 +54,12 @@ const char *usage = "\n" "\t-q Only output information from YubiKey\n" "\n" + "\t-V Get the tool version\n" "\t-h help (this text)\n" "\n" "\n" ; -const char *optstring = "asmHvtpqh"; +const char *optstring = "asmHvtpqhV"; static void report_yk_error(void) { @@ -110,6 +112,10 @@ static int parse_args(int argc, char **argv, case 'q': *quiet = true; break; + case 'V': + fputs(YKPERS_VERSION_STRING "\n", stderr); + *exit_code = 0; + return 0; case 'h': default: fputs(usage, stderr); diff --git a/ykpers-args.c b/ykpers-args.c index 35ddd65..dcfcdf4 100644 --- a/ykpers-args.c +++ b/ykpers-args.c @@ -40,6 +40,7 @@ #include #include /* To get yubikey_modhex_encode and yubikey_hex_encode */ #include +#include #include "ykpers-args.h" #define YUBICO_OATH_VENDOR_ID_HEX 0xe1 /* UB as hex */ @@ -157,9 +158,10 @@ const char *usage = "-d dry-run (don't write anything to key)\n" "\n" "-v verbose\n" +"-V tool version\n" "-h help (this text)\n" ; -const char *optstring = "u12xza:c:n:t:hi:o:s:f:dvym:S::"; +const char *optstring = "u12xza:c:n:t:hi:o:s:f:dvym:S::V"; static int _set_fixed(char *opt, YKP_CONFIG *cfg); static int _format_decimal_as_hex(uint8_t *dst, size_t dst_len, uint8_t *src); @@ -671,6 +673,10 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, YK_KEY *yk, case 'y': *autocommit = true; break; + case 'V': + fputs(YKPERS_VERSION_STRING "\n", stderr); + *exit_code = 0; + return 0; case 'h': default: fputs(usage, stderr); diff --git a/ykpersonalize.1 b/ykpersonalize.1 index ffaa556..e311911 100644 --- a/ykpersonalize.1 +++ b/ykpersonalize.1 @@ -38,7 +38,7 @@ ykpersonalize - personalize YubiKey OTP tokens .B ykpersonalize [\fI-1\fR | \fI-2\fR] [\fI-sfile\fR] [\fI-ifile\fR] [\fI-fformat\fR] [\fI-axxx\fR] [\fI-cxxx\fR] [\fI-ooption\fR] [\fI-y\fR] [\fI-v\fR] [\fI-d\fR] [\fI-h\fR] [\fI-n\fR] [\fI-t\fR] [\fI-u\fR] [\fI-x\fR] -[\fI-z\fR] [\fI-m\fR] [\fI-S\fR] +[\fI-z\fR] [\fI-m\fR] [\fI-S\fR] [\fI-V\fR] .\".SH DESCRIPTION .\" Add any additional description here .SH OPTIONS @@ -133,6 +133,9 @@ Be more verbose \fB-h\fR Help .TP +\fB-V\fR +Version +.TP \fBYubiKey NEO only\fR .RS .TP -- 2.39.5