From a92aeca1115cbaa787e5d1e46b9357d922cf2f5b Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 24 Aug 2022 19:21:39 +0100 Subject: [PATCH] Pass port through to userauth. I'm going to want to use it in an upcoming commit, because together with 'savedhost', it forms the identification of an SSH server (at least as far as the host key cache is concerned, and therefore it's appropriate for other uses too). We were already passing the hostname through for use in user-facing prompts (not to mention the FQDN version for use in GSSAPI). --- ssh/ppl.h | 2 +- ssh/ssh.c | 3 ++- ssh/userauth2-client.c | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ssh/ppl.h b/ssh/ppl.h index 025a5615..4ffeffe9 100644 --- a/ssh/ppl.h +++ b/ssh/ppl.h @@ -109,7 +109,7 @@ PacketProtocolLayer *ssh2_transport_new( const SshServerConfig *ssc); PacketProtocolLayer *ssh2_userauth_new( PacketProtocolLayer *successor_layer, - const char *hostname, const char *fullhostname, + const char *hostname, int port, const char *fullhostname, Filename *keyfile, Filename *detached_cert, bool show_banner, bool tryagent, bool notrivialauth, const char *default_username, bool change_username, diff --git a/ssh/ssh.c b/ssh/ssh.c index c7e03ff8..aba09769 100644 --- a/ssh/ssh.c +++ b/ssh/ssh.c @@ -253,7 +253,8 @@ static void ssh_got_ssh_version(struct ssh_version_receiver *rcv, char *username = get_remote_username(ssh->conf); userauth_layer = ssh2_userauth_new( - connection_layer, ssh->savedhost, ssh->fullhostname, + connection_layer, ssh->savedhost, ssh->savedport, + ssh->fullhostname, conf_get_filename(ssh->conf, CONF_keyfile), conf_get_filename(ssh->conf, CONF_detached_cert), conf_get_bool(ssh->conf, CONF_ssh_show_banner), diff --git a/ssh/userauth2-client.c b/ssh/userauth2-client.c index 5f7a9b52..836e89fb 100644 --- a/ssh/userauth2-client.c +++ b/ssh/userauth2-client.c @@ -30,6 +30,7 @@ struct ssh2_userauth_state { Filename *keyfile, *detached_cert_file; bool show_banner, tryagent, notrivialauth, change_username; char *hostname, *fullhostname; + int port; char *default_username; bool try_ki_auth, try_gssapi_auth, try_gssapi_kex_auth, gssapi_fwd; @@ -129,7 +130,7 @@ static const PacketProtocolLayerVtable ssh2_userauth_vtable = { PacketProtocolLayer *ssh2_userauth_new( PacketProtocolLayer *successor_layer, - const char *hostname, const char *fullhostname, + const char *hostname, int port, const char *fullhostname, Filename *keyfile, Filename *detached_cert_file, bool show_banner, bool tryagent, bool notrivialauth, const char *default_username, bool change_username, @@ -142,6 +143,7 @@ PacketProtocolLayer *ssh2_userauth_new( s->successor_layer = successor_layer; s->hostname = dupstr(hostname); + s->port = port; s->fullhostname = dupstr(fullhostname); s->keyfile = filename_copy(keyfile); s->detached_cert_file = filename_copy(detached_cert_file);