summaryrefslogtreecommitdiff
path: root/readpass.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2019-06-05 06:41:44 +0100
committerColin Watson <cjwatson@debian.org>2019-06-05 06:41:44 +0100
commit102062f825fb26a74295a1c089c00c4c4c76b68a (patch)
tree3db66bc8c8483cce66516dff36f6ef56065143d9 /readpass.c
parent3d246f10429fc9a37b98eabef94fe8dc7c61002b (diff)
parentfd0fa130ecf06d7d092932adcd5d77f1549bfc8d (diff)
Import openssh_8.0p1.orig.tar.gz
Diffstat (limited to 'readpass.c')
-rw-r--r--readpass.c15
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)
117char * 117char *
118read_passphrase(const char *prompt, int flags) 118read_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;