[sshconnect2.c]
     Use the HostKeyAlias when prompting for passwords.  bz#1039, ok djm@
This commit is contained in:
Darren Tucker 2010-01-08 18:48:02 +11:00
parent 210631922f
commit ab79169e29
2 changed files with 12 additions and 5 deletions

View File

@ -78,6 +78,9 @@
and delay it until after the sftp protocol connection has been established. and delay it until after the sftp protocol connection has been established.
Avoids confusing sequence of messages when the underlying ssh connection Avoids confusing sequence of messages when the underlying ssh connection
experiences problems. ok dtucker@ experiences problems. ok dtucker@
- dtucker@cvs.openbsd.org 2009/11/20 00:59:36
[sshconnect2.c]
Use the HostKeyAlias when prompting for passwords. bz#1039, ok djm@
20091226 20091226
- (tim) [contrib/cygwin/Makefile] Install ssh-copy-id and ssh-copy-id.1 - (tim) [contrib/cygwin/Makefile] Install ssh-copy-id and ssh-copy-id.1

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sshconnect2.c,v 1.174 2009/11/10 04:30:45 dtucker Exp $ */ /* $OpenBSD: sshconnect2.c,v 1.175 2009/11/20 00:59:36 dtucker Exp $ */
/* /*
* Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2000 Markus Friedl. All rights reserved.
* Copyright (c) 2008 Damien Miller. All rights reserved. * Copyright (c) 2008 Damien Miller. All rights reserved.
@ -804,6 +804,8 @@ userauth_passwd(Authctxt *authctxt)
static int attempt = 0; static int attempt = 0;
char prompt[150]; char prompt[150];
char *password; char *password;
const char *host = options.host_key_alias ? options.host_key_alias :
authctxt->host;
if (attempt++ >= options.number_of_password_prompts) if (attempt++ >= options.number_of_password_prompts)
return 0; return 0;
@ -812,7 +814,7 @@ userauth_passwd(Authctxt *authctxt)
error("Permission denied, please try again."); error("Permission denied, please try again.");
snprintf(prompt, sizeof(prompt), "%.30s@%.128s's password: ", snprintf(prompt, sizeof(prompt), "%.30s@%.128s's password: ",
authctxt->server_user, authctxt->host); authctxt->server_user, host);
password = read_passphrase(prompt, 0); password = read_passphrase(prompt, 0);
packet_start(SSH2_MSG_USERAUTH_REQUEST); packet_start(SSH2_MSG_USERAUTH_REQUEST);
packet_put_cstring(authctxt->server_user); packet_put_cstring(authctxt->server_user);
@ -841,6 +843,8 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
Authctxt *authctxt = ctxt; Authctxt *authctxt = ctxt;
char *info, *lang, *password = NULL, *retype = NULL; char *info, *lang, *password = NULL, *retype = NULL;
char prompt[150]; char prompt[150];
const char *host = options.host_key_alias ? options.host_key_alias :
authctxt->host;
debug2("input_userauth_passwd_changereq"); debug2("input_userauth_passwd_changereq");
@ -861,7 +865,7 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
packet_put_char(1); /* additional info */ packet_put_char(1); /* additional info */
snprintf(prompt, sizeof(prompt), snprintf(prompt, sizeof(prompt),
"Enter %.30s@%.128s's old password: ", "Enter %.30s@%.128s's old password: ",
authctxt->server_user, authctxt->host); authctxt->server_user, host);
password = read_passphrase(prompt, 0); password = read_passphrase(prompt, 0);
packet_put_cstring(password); packet_put_cstring(password);
memset(password, 0, strlen(password)); memset(password, 0, strlen(password));
@ -870,7 +874,7 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
while (password == NULL) { while (password == NULL) {
snprintf(prompt, sizeof(prompt), snprintf(prompt, sizeof(prompt),
"Enter %.30s@%.128s's new password: ", "Enter %.30s@%.128s's new password: ",
authctxt->server_user, authctxt->host); authctxt->server_user, host);
password = read_passphrase(prompt, RP_ALLOW_EOF); password = read_passphrase(prompt, RP_ALLOW_EOF);
if (password == NULL) { if (password == NULL) {
/* bail out */ /* bail out */
@ -878,7 +882,7 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
} }
snprintf(prompt, sizeof(prompt), snprintf(prompt, sizeof(prompt),
"Retype %.30s@%.128s's new password: ", "Retype %.30s@%.128s's new password: ",
authctxt->server_user, authctxt->host); authctxt->server_user, host);
retype = read_passphrase(prompt, 0); retype = read_passphrase(prompt, 0);
if (strcmp(password, retype) != 0) { if (strcmp(password, retype) != 0) {
memset(password, 0, strlen(password)); memset(password, 0, strlen(password));