diff options
Diffstat (limited to 'readpass.c')
-rw-r--r-- | readpass.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/readpass.c b/readpass.c index f160f866b..44014ef8a 100644 --- a/readpass.c +++ b/readpass.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: readpass.c,v 1.52 2018/07/18 11:34:04 dtucker Exp $ */ | 1 | /* $OpenBSD: readpass.c,v 1.53 2019/01/19 04:15:56 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. |
4 | * | 4 | * |
@@ -117,7 +117,7 @@ ssh_askpass(char *askpass, const char *msg) | |||
117 | char * | 117 | char * |
118 | read_passphrase(const char *prompt, int flags) | 118 | read_passphrase(const char *prompt, int flags) |
119 | { | 119 | { |
120 | char *askpass = NULL, *ret, buf[1024]; | 120 | char cr = '\r', *askpass = NULL, *ret, buf[1024]; |
121 | int rppflags, use_askpass = 0, ttyfd; | 121 | int rppflags, use_askpass = 0, ttyfd; |
122 | 122 | ||
123 | rppflags = (flags & RP_ECHO) ? RPP_ECHO_ON : RPP_ECHO_OFF; | 123 | rppflags = (flags & RP_ECHO) ? RPP_ECHO_ON : RPP_ECHO_OFF; |
@@ -131,9 +131,16 @@ read_passphrase(const char *prompt, int flags) | |||
131 | } else { | 131 | } else { |
132 | rppflags |= RPP_REQUIRE_TTY; | 132 | rppflags |= RPP_REQUIRE_TTY; |
133 | ttyfd = open(_PATH_TTY, O_RDWR); | 133 | ttyfd = open(_PATH_TTY, O_RDWR); |
134 | if (ttyfd >= 0) | 134 | if (ttyfd >= 0) { |
135 | /* | ||
136 | * If we're on a tty, ensure that show the prompt at | ||
137 | * the beginning of the line. This will hopefully | ||
138 | * clobber any password characters the user has | ||
139 | * optimistically typed before echo is disabled. | ||
140 | */ | ||
141 | (void)write(ttyfd, &cr, 1); | ||
135 | close(ttyfd); | 142 | close(ttyfd); |
136 | else { | 143 | } else { |
137 | debug("read_passphrase: can't open %s: %s", _PATH_TTY, | 144 | debug("read_passphrase: can't open %s: %s", _PATH_TTY, |
138 | strerror(errno)); | 145 | strerror(errno)); |
139 | use_askpass = 1; | 146 | use_askpass = 1; |