From 9e363e9311172602de4815aa72e6a4c597715bd0 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Mon, 22 Sep 2014 21:00:50 +0200 Subject: [PATCH] Make repeating password optional with -r This is useful when creating a new password, but annoying when just using it to calculate the password to log in. --- main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index b7baaf6..ce9aeb1 100644 --- a/main.c +++ b/main.c @@ -43,7 +43,7 @@ usage(void) fprintf(stderr, "Usage: scrypt-genpass [-l LEN] [-m MAXMEM] [-n] [-o MAXOPS] [-k KEYFILE]\n"); fprintf(stderr, - " [-p PASS] \n"); + " [-p PASS] [-r] [-v] \n"); fprintf(stderr, " scrypt-genpass -t\n"); fprintf(stderr, @@ -92,6 +92,7 @@ main(int argc, char *argv[]) char ch; int rc; + bool repeat = false; #ifdef NEED_WARN_PROGNAME warn_progname = "scrypt-genpass"; @@ -102,7 +103,7 @@ main(int argc, char *argv[]) init_parms(&sg_parms); /* Parse arguments. */ - while ((ch = getopt(argc, argv, "htk:l:m:no:p:v")) != -1) { + while ((ch = getopt(argc, argv, "htk:l:m:no:p:rv")) != -1) { switch (ch) { case 'k': sg_parms.keyfile = strdup(optarg); @@ -125,6 +126,9 @@ main(int argc, char *argv[]) case 't': unit_tests(); break; + case 'r': + repeat = true; + break; case 'v': sg_parms.verbose = 1; break; @@ -142,7 +146,7 @@ main(int argc, char *argv[]) if (!sg_parms.passwd) { /* Prompt for a password. */ if (tarsnap_readpass((char**)&(sg_parms.passwd), "Please enter passphrase", - "Please confirm passphrase", 1)) + (repeat ? "Please repeat passphrase" : NULL), 1)) exit(1); } sg_parms.passwdlen = strlen(sg_parms.passwd);