diff --git a/ykpamcfg.1.txt b/ykpamcfg.1.txt index c4c7314..fdd713a 100644 --- a/ykpamcfg.1.txt +++ b/ykpamcfg.1.txt @@ -8,7 +8,7 @@ YKPAMCFG(1) ykpamcfg - Manage user settings for the Yubico PAM module == SYNOPSIS -*ykmapcfg* [-1 | -2] [-A] [-p] [-i] [-v] [-h] +*ykmapcfg* [-1 | -2] [-A] [-p] [-i] [-v] [-V] [-h] == OPTIONS *-1*:: @@ -29,6 +29,12 @@ number of iterations to use for pbkdf2 of expected response *-v*:: enable verbose mode. +*-V*:: +display version and exit + +*-h*:: +display help and exit + == ACTIONS === add_hmac_chalresp The PAM module can utilize the HMAC-SHA1 Challenge-Response mode found in YubiKeys starting with version 2.2 for *offline authentication*. This action creates the initial state information with the C/R to be issued at the next logon. diff --git a/ykpamcfg.c b/ykpamcfg.c index 21e7f7c..ae70819 100644 --- a/ykpamcfg.c +++ b/ykpamcfg.c @@ -59,8 +59,9 @@ const char *usage = "\t-p path Specify an output path for the challenge file.\n" "\t-i iters Number of iterations to use for pbkdf2 (defaults to 10000)\n" "\n" - "\t-v verbose\n" - "\t-h help (this text)\n" + "\t-v Increase verbosity\n" + "\t-V Show version and exit\n" + "\t-h Show help (this text) and exit\n" "\n" "Actions :\n" "\n" @@ -68,7 +69,7 @@ const char *usage = "\n" "\n" ; -const char *optstring = "12A:p:i:vh"; +const char *optstring = "12A:p:i:vVh"; static void report_yk_error(void) @@ -91,8 +92,7 @@ static int parse_args(int argc, char **argv, int *slot, bool *verbose, char **action, char **output_dir, - unsigned int *iterations, - int *exit_code) + unsigned int *iterations) { int c; @@ -111,21 +111,25 @@ parse_args(int argc, char **argv, *output_dir = optarg; break; case 'i': - *iterations = strtoul(optarg, NULL, 10); - if(*iterations == 0) { - fprintf(stderr, "iterations must be numeric, %s isn't.\n", optarg); - *exit_code = 1; - return 0; + { + char *endptr; + *iterations = strtoul(optarg, &endptr, 10); + if(*endptr != '\0') { + fprintf(stderr, "iterations must be numeric, %s isn't.\n", optarg); + exit(1); + } } break; case 'v': *verbose = true; break; + case 'V': + printf("%s\n", VERSION); + exit(0); case 'h': default: fputs(usage, stderr); - *exit_code = 0; - return 0; + exit(0); } } @@ -272,7 +276,7 @@ main(int argc, char **argv) if (! parse_args(argc, argv, &slot, &verbose, &ptr, &output_dir, - &iterations, &exit_code)) + &iterations)) goto err; exit_code = 1;