config: Allow setting username from configuration

... file, even if it was already set before. The options
level handles what was already set.

The proxyJump implementation sets the username from the proxyjump, which
is setting it to NULL, effectively writing the current username to the
new session, which was not possible to override due to the following check.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2025-10-14 22:50:45 +02:00
parent d0d45c8915
commit 320844669a

View File

@@ -1177,14 +1177,12 @@ static int ssh_config_parse_line_internal(ssh_session session,
} }
break; break;
case SOC_USERNAME: case SOC_USERNAME:
if (session->opts.username == NULL) { p = ssh_config_get_str_tok(&s, NULL);
p = ssh_config_get_str_tok(&s, NULL); CHECK_COND_OR_FAIL(p == NULL, "Missing argument");
CHECK_COND_OR_FAIL(p == NULL, "Missing argument"); if (*parsing) {
if (*parsing) { ssh_options_set(session, SSH_OPTIONS_USER, p);
ssh_options_set(session, SSH_OPTIONS_USER, p); }
} break;
}
break;
case SOC_IDENTITY: case SOC_IDENTITY:
p = ssh_config_get_str_tok(&s, NULL); p = ssh_config_get_str_tok(&s, NULL);
CHECK_COND_OR_FAIL(p == NULL, "Missing argument"); CHECK_COND_OR_FAIL(p == NULL, "Missing argument");