X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/be774c585cb5d4fd03c7f56eb8de7adee8229992..12100b9c9ed2a7fefa1621345bc91e88473001dd:/ssh.c diff --git a/ssh.c b/ssh.c index d028974c..8c71e6df 100644 --- a/ssh.c +++ b/ssh.c @@ -2757,7 +2757,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen, int ispkt) fflush(stdout); { - if ((flags & FLAG_INTERACTIVE) && !*ssh->cfg.username) { + if (!*ssh->cfg.username) { if (ssh_get_line && !ssh_getline_pw_only) { if (!ssh_get_line("login as: ", s->username, sizeof(s->username), FALSE)) { @@ -3582,7 +3582,8 @@ static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt) } if (sport && dport) { /* Set up a description of the source port. */ - char *sportdesc = dupprintf("%.*s%.*s%.*s%.*s%d%.*s", + static char *sportdesc; + sportdesc = dupprintf("%.*s%.*s%.*s%.*s%d%.*s", (int)(*saddr?strlen(saddr):0), *saddr?saddr:NULL, (int)(*saddr?1:0), ":", (int)(sserv ? strlen(sports) : 0), sports, @@ -4840,7 +4841,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt) * with change_username turned off we don't try to get * it again. */ - } else if ((flags & FLAG_INTERACTIVE) && !*ssh->cfg.username) { + } else if (!*ssh->cfg.username) { if (ssh_get_line && !ssh_getline_pw_only) { if (!ssh_get_line("login as: ", s->username, sizeof(s->username), FALSE)) { @@ -5002,7 +5003,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt) * Additionally, if we'd just tried password * authentication, we should break out of this * whole loop so as to go back to the username - * prompt. + * prompt (iff we're configured to allow + * username change attempts). */ if (s->type == AUTH_TYPE_NONE) { /* do nothing */ @@ -5016,7 +5018,10 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt) } else { c_write_str(ssh, "Access denied\r\n"); logevent("Access denied"); - if (s->type == AUTH_TYPE_PASSWORD) { + if (s->type == AUTH_TYPE_PASSWORD && + ssh->cfg.change_username) { + /* XXX perhaps we should allow + * keyboard-interactive to do this too? */ s->we_are_in = FALSE; break; } @@ -5770,7 +5775,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt) } if (sport && dport) { /* Set up a description of the source port. */ - static char *sportdesc = dupprintf("%.*s%.*s%.*s%.*s%d%.*s", + static char *sportdesc; + sportdesc = dupprintf("%.*s%.*s%.*s%.*s%d%.*s", (int)(*saddr?strlen(saddr):0), *saddr?saddr:NULL, (int)(*saddr?1:0), ":", (int)(sserv ? strlen(sports) : 0), sports, @@ -5823,12 +5829,13 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt) ssh2_pkt_init(ssh, SSH2_MSG_GLOBAL_REQUEST); ssh2_pkt_addstring(ssh, "tcpip-forward"); ssh2_pkt_addbool(ssh, 1);/* want reply */ - if (*saddr) + if (*saddr) { ssh2_pkt_addstring(ssh, saddr); - if (ssh->cfg.rport_acceptall) + } else if (ssh->cfg.rport_acceptall) { ssh2_pkt_addstring(ssh, "0.0.0.0"); - else + } else { ssh2_pkt_addstring(ssh, "127.0.0.1"); + } ssh2_pkt_adduint32(ssh, sport); ssh2_pkt_send(ssh);