There is a missing rip() before the strtonum(). The rest of the
diff allows the -n option to work with -s.
- todd
Index: usr.bin/skeyinit/skeyinit.c
===================================================================
RCS file: /cvs/src/usr.bin/skeyinit/skeyinit.c,v
retrieving revision 1.62
diff -u -p -u -r1.62 skeyinit.c
--- usr.bin/skeyinit/skeyinit.c 20 Nov 2015 20:57:48 -0000 1.62
+++ usr.bin/skeyinit/skeyinit.c 29 Nov 2015 03:05:42 -0000
@@ -271,7 +271,7 @@ main(int argc, char **argv)
if (fchown(fileno(skey.keyfile), pp->pw_uid, -1) != 0 ||
fchmod(fileno(skey.keyfile), S_IRUSR | S_IWUSR) != 0)
err(1, "can't set owner/mode for %s", pp->pw_name);
- if (n == 0)
+ if (defaultsetup && n == 0)
n = 100;
/* Set hash type if asked to */
@@ -308,22 +308,27 @@ secure_mode(int *count, char *key, char
{
char *p, newseed[SKEY_MAX_SEED_LEN + 2];
const char *errstr;
- int i, n;
+ int i, n = *count;
(void)puts("You need the 6 words generated from the \"skey\" command.");
- for (i = 0; ; i++) {
- if (i >= 2)
- exit(1);
-
- (void)printf("Enter sequence count from 1 to %d: ",
- SKEY_MAX_SEQ);
- (void)fgets(buf, bufsiz, stdin);
- clearerr(stdin);
- n = strtonum(buf, 1, SKEY_MAX_SEQ-1, &errstr);
- if (!errstr)
- break; /* Valid range */
- fprintf(stderr, "ERROR: Count must be between 1 and %d\n",
- SKEY_MAX_SEQ - 1);
+ if (n == 0) {
+ for (i = 0; ; i++) {
+ if (i >= 2)
+ exit(1);
+
+ (void)printf("Enter sequence count from 1 to %d: ",
+ SKEY_MAX_SEQ);
+ (void)fgets(buf, bufsiz, stdin);
+ clearerr(stdin);
+ rip(buf);
+ n = strtonum(buf, 1, SKEY_MAX_SEQ-1, &errstr);
+ if (!errstr)
+ break; /* Valid range */
+ fprintf(stderr,
+ "ERROR: Count must be between 1 and %d\n",
+ SKEY_MAX_SEQ - 1);
+ }
+ *count= n;
}
for (i = 0; ; i++) {
@@ -381,7 +386,6 @@ secure_mode(int *count, char *key, char
(void)fputs("ERROR: Invalid format - try again with the 6
words.\n",
stderr);
}
- *count= n;
}
void