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>
(cherry picked from commit 320844669a)
This commit is contained in:
Jakub Jelen
2025-10-14 22:50:45 +02:00
parent d61b0dc7cc
commit 77ce02d809

View File

@@ -1066,13 +1066,11 @@ ssh_config_parse_line(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); if (p && *parsing) {
if (p && *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);
if (p && *parsing) { if (p && *parsing) {