Hi,
If you SIGINT or SIGQUIT at a lock(1) prompt, the secondary header
is printed twice, like this:
Key:
lock: type in the unlock key. timeout in 14:54 minutes
lock: type in the unlock key. timeout in 14:54 minutes
This is because we call the signal handler that prints the
secondary header after readpassphrase(3) returns NULL, even
though readpassphrase() resends SIGINT and SIGQUIT if it
catches them while trying to read a password.
This patch changes the logic so that we merely re-prompt when
readpassphrase() returns NULL, and only explicitly call the
signal handler when readpassphrase() hands us back a zero-length
password, which indicates that the user just hit enter or sent
an EOT.
--
Scott Cheloha
Index: usr.bin/lock/lock.c
===================================================================
RCS file: /cvs/src/usr.bin/lock/lock.c,v
retrieving revision 1.34
diff -u -p -r1.34 lock.c
--- usr.bin/lock/lock.c 3 May 2017 09:51:39 -0000 1.34
+++ usr.bin/lock/lock.c 8 Jul 2017 14:03:17 -0000
@@ -188,8 +188,9 @@ main(int argc, char *argv[])
}
for (cnt = 0;;) {
- if (!readpassphrase("Key: ", s, sizeof(s), RPP_ECHO_OFF) ||
- *s == '\0') {
+ if (!readpassphrase("Key: ", s, sizeof(s), RPP_ECHO_OFF))
+ continue;
+ if (strlen(s) == 0) {
hi(0);
continue;
}