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)) {
}
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,
* 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)) {
* 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 */
} 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;
}