History log of /openbsd-current/lib/libc/gen/readpassphrase.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.27 25-Jan-2019 millert

I am retiring my old email address; replace it with my OpenBSD one.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.26 18-Oct-2016 millert

Avoid generate SIGTTOU when restoring the terminal mode. If we get
SIGTTOU it means the process is not in the foreground process group
which, in most cases, means that the shell has taken control of the
tty. Requiring the user the fg the process in this case doesn't
make sense and can result in both SIGTSTP and SIGTTOU being sent
which can lead to the process being suspended again immediately
after being brought into the foreground.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.25 14-Sep-2015 guenther

Wrap <readpassphrase.h> so internal calls go direct and readpassphrase is weak


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.24 24-Nov-2013 deraadt

most obvious unsigned char casts for ctype
ok jca krw ingo


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.23 14-May-2010 millert

Defer installing signal handlers until echo is disabled so that we
get suspended normally when not the foreground process. Fix potential
infinite loop when restoring terminal settings if process is in the
background when restore occurs. OK miod@


Revision tags: OPENBSD_4_7_BASE
# 1.22 13-Jan-2010 dtucker

If a process receives two different signals while in readpassphrase, only
the most recent one will be stored for later re-delivery. When the signal
handlers are restored, all except the most recent signal will be lost.
Replace the single variable with an array so signals are not lost.
ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.21 17-Jan-2008 millert

Use TCSAFLUSH instead of TCSANOW when turning echo back on so that
there is no chance of output that was written but still pending to
be displayed. This is what the original getpass(3) did.


# 1.20 30-Oct-2007 millert

If we receive SIGTTOU when turning off echo, the process is already
backgrounded. Do not print the password prompt in this case since
the first read will result in the process receiving SIGTTIN.
Fixes an issue where the password prompt would be displayed when
readpassphrase() would not be able to read anything. OK deraadt@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.19 31-Mar-2006 deraadt

(char)to{upper,lower}()


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.18 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.17 24-May-2005 millert

Restoration of terminal settings can be broken by a well-timed signal,
e.g. a terminating scp killing its ssh child so retry on EINTR.
From peak@argo.troja.mff.cuni.cz via portable openssh bugzilla #905


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.16 17-Jun-2003 millert

Sync with share/misc/license.template and add missing DARPA credit
where applicable.


# 1.15 03-Jun-2003 millert

Use an ISC-tyle license for all my code; it is simpler and more permissive.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.14 28-Jun-2002 millert

Add RPP_STDIN flag which acts as the converse of RPP_REQUIRE_TTY.
Based on a patch from Brett Eldridge.


# 1.13 09-May-2002 millert

Add SIGALRM and SIGPIPE to the list of signals we catch, turn echo back on,
and then re-deliver. Note that for this to work with setugid processes,
the recent fix to cansignal() in kern_sig.c is required.


Revision tags: OPENBSD_3_1_BASE
# 1.12 15-Dec-2001 millert

Catch SIGTTIN and SIGTTOU too and treat them like SIGTSTP.


# 1.11 07-Dec-2001 millert

o Turn off ECHONL in addition to ECHO
o Return NULL of read(2) returns -1
o Add ERRORS and STANDARDS sections


# 1.10 07-Dec-2001 millert

Instead of restoring the tty mode, restoring the signal handler,
unblocking the signal and redelivering it just make all our
signal handler interupt system calls and set a flag. We can just
deliver the signal at the end right before we would normally return.
This solves the SIG_IGN problem nicely and causes readpassphrase() to
return when someone hits ^C even if the handler is SIG_IGN.


# 1.9 06-Dec-2001 millert

Use TCSAFLUSH not TCSANOW. I was only using TCSANOW during debugging...


# 1.8 06-Dec-2001 millert

Fix a long standing annoyance with getpass/readpassphrase. Instead of
blocking SIGINT and SIGTSTP, catch them (along with SIGHUP, SIGQUIT, SIGTERM).
We restore the tty mode as needed and then restore the original signal
handler and resend the signal. For SIGTSTP, upon return from suspend
the user is re-prompted for the passphrase.


Revision tags: OPENBSD_3_0_BASE
# 1.7 07-Aug-2001 millert

Do the memset only if tcgetattr() fails just in case the failed
tcgetattr() mucked with the passed in struct termios in some way.


# 1.6 07-Aug-2001 millert

Keep a verbatim copy of the old struct termios instead of using
flags to keep track of what we changed. Print a newline if echo
is off, even if we didn't turn it off ourselves. Fixes art's
problem with a newline not being printed when piping to less.


# 1.5 27-Jun-2001 djm

typo, spotted by Tom Holroyd <tomh@po.crl.go.jp>; ok deraadt@


# 1.4 18-Jun-2001 millert

Fix a char vs. u_char problem I introduced in the last commit.


# 1.3 16-Jun-2001 millert

Disable the STATUS character when reading passwords -- people seem to
expect to be able to use ^T in a password.


Revision tags: OPENBSD_2_9_BASE
# 1.2 29-Nov-2000 millert

Don't print an extra newline after reading passphrase if echo was not
turned off since we already printed one from the user.


# 1.1 21-Nov-2000 millert

Add readpasasphrase(3), a more flexible getpass(3) replacement.
getpass(3) is now implemented in terms of readpasasphrase(3).


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.26 18-Oct-2016 millert

Avoid generate SIGTTOU when restoring the terminal mode. If we get
SIGTTOU it means the process is not in the foreground process group
which, in most cases, means that the shell has taken control of the
tty. Requiring the user the fg the process in this case doesn't
make sense and can result in both SIGTSTP and SIGTTOU being sent
which can lead to the process being suspended again immediately
after being brought into the foreground.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.25 14-Sep-2015 guenther

Wrap <readpassphrase.h> so internal calls go direct and readpassphrase is weak


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.24 24-Nov-2013 deraadt

most obvious unsigned char casts for ctype
ok jca krw ingo


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.23 14-May-2010 millert

Defer installing signal handlers until echo is disabled so that we
get suspended normally when not the foreground process. Fix potential
infinite loop when restoring terminal settings if process is in the
background when restore occurs. OK miod@


Revision tags: OPENBSD_4_7_BASE
# 1.22 13-Jan-2010 dtucker

If a process receives two different signals while in readpassphrase, only
the most recent one will be stored for later re-delivery. When the signal
handlers are restored, all except the most recent signal will be lost.
Replace the single variable with an array so signals are not lost.
ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.21 17-Jan-2008 millert

Use TCSAFLUSH instead of TCSANOW when turning echo back on so that
there is no chance of output that was written but still pending to
be displayed. This is what the original getpass(3) did.


# 1.20 30-Oct-2007 millert

If we receive SIGTTOU when turning off echo, the process is already
backgrounded. Do not print the password prompt in this case since
the first read will result in the process receiving SIGTTIN.
Fixes an issue where the password prompt would be displayed when
readpassphrase() would not be able to read anything. OK deraadt@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.19 31-Mar-2006 deraadt

(char)to{upper,lower}()


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.18 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.17 24-May-2005 millert

Restoration of terminal settings can be broken by a well-timed signal,
e.g. a terminating scp killing its ssh child so retry on EINTR.
From peak@argo.troja.mff.cuni.cz via portable openssh bugzilla #905


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.16 17-Jun-2003 millert

Sync with share/misc/license.template and add missing DARPA credit
where applicable.


# 1.15 03-Jun-2003 millert

Use an ISC-tyle license for all my code; it is simpler and more permissive.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.14 28-Jun-2002 millert

Add RPP_STDIN flag which acts as the converse of RPP_REQUIRE_TTY.
Based on a patch from Brett Eldridge.


# 1.13 09-May-2002 millert

Add SIGALRM and SIGPIPE to the list of signals we catch, turn echo back on,
and then re-deliver. Note that for this to work with setugid processes,
the recent fix to cansignal() in kern_sig.c is required.


Revision tags: OPENBSD_3_1_BASE
# 1.12 15-Dec-2001 millert

Catch SIGTTIN and SIGTTOU too and treat them like SIGTSTP.


# 1.11 07-Dec-2001 millert

o Turn off ECHONL in addition to ECHO
o Return NULL of read(2) returns -1
o Add ERRORS and STANDARDS sections


# 1.10 07-Dec-2001 millert

Instead of restoring the tty mode, restoring the signal handler,
unblocking the signal and redelivering it just make all our
signal handler interupt system calls and set a flag. We can just
deliver the signal at the end right before we would normally return.
This solves the SIG_IGN problem nicely and causes readpassphrase() to
return when someone hits ^C even if the handler is SIG_IGN.


# 1.9 06-Dec-2001 millert

Use TCSAFLUSH not TCSANOW. I was only using TCSANOW during debugging...


# 1.8 06-Dec-2001 millert

Fix a long standing annoyance with getpass/readpassphrase. Instead of
blocking SIGINT and SIGTSTP, catch them (along with SIGHUP, SIGQUIT, SIGTERM).
We restore the tty mode as needed and then restore the original signal
handler and resend the signal. For SIGTSTP, upon return from suspend
the user is re-prompted for the passphrase.


Revision tags: OPENBSD_3_0_BASE
# 1.7 07-Aug-2001 millert

Do the memset only if tcgetattr() fails just in case the failed
tcgetattr() mucked with the passed in struct termios in some way.


# 1.6 07-Aug-2001 millert

Keep a verbatim copy of the old struct termios instead of using
flags to keep track of what we changed. Print a newline if echo
is off, even if we didn't turn it off ourselves. Fixes art's
problem with a newline not being printed when piping to less.


# 1.5 27-Jun-2001 djm

typo, spotted by Tom Holroyd <tomh@po.crl.go.jp>; ok deraadt@


# 1.4 18-Jun-2001 millert

Fix a char vs. u_char problem I introduced in the last commit.


# 1.3 16-Jun-2001 millert

Disable the STATUS character when reading passwords -- people seem to
expect to be able to use ^T in a password.


Revision tags: OPENBSD_2_9_BASE
# 1.2 29-Nov-2000 millert

Don't print an extra newline after reading passphrase if echo was not
turned off since we already printed one from the user.


# 1.1 21-Nov-2000 millert

Add readpasasphrase(3), a more flexible getpass(3) replacement.
getpass(3) is now implemented in terms of readpasasphrase(3).