From 568aa9295f4cdba8a959356acc929ca6dfd6aab0 Mon Sep 17 00:00:00 2001 From: "Alejandro E. Brito Monedero" Date: Wed, 19 Feb 2020 13:00:48 +0100 Subject: [PATCH] Use tmate-server-port when using libssh 0.9 * Since libssh 0.9 doing ssh_connect will call parse_config (unless it is deactivated SSH_OPTIONS_PROCESS_CONFIG) if ~/.ssh/config hasn't been parsed, overwriting the port option. So this will call parse_first before setting the port with tmate-server-port as commit 89a8a6fcf07368c56a98ff8168db77b6814fbe7b. Fixes #167 Commit 89a8a6fcf07368c56a98ff8168db77b6814fbe7b in libssh As the configuration parsing is the last thing before doing the actual connection, it might overwrite previously set options. If this is not intended, the client application can ask the configuration files to be parsed before setting some other options that should not ve overwritten. --- tmate-ssh-client.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tmate-ssh-client.c b/tmate-ssh-client.c index c52c166c..cd1231c2 100644 --- a/tmate-ssh-client.c +++ b/tmate-ssh-client.c @@ -269,7 +269,6 @@ static void on_ssh_client_event(struct tmate_ssh_client *client) ssh_set_blocking(session, 0); ssh_options_set(session, SSH_OPTIONS_HOST, client->server_ip); ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); - ssh_options_set(session, SSH_OPTIONS_PORT, &port); ssh_options_set(session, SSH_OPTIONS_USER, "tmate"); ssh_options_set(session, SSH_OPTIONS_COMPRESSION, "yes"); @@ -287,6 +286,14 @@ static void on_ssh_client_event(struct tmate_ssh_client *client) free(identity); } + /* + * libssh 0.9 calls parse_config if it hasn't been parsed + * when doing a ssh_connect overwriting the port. + * So this overwrites port with our tmate-server-port config. + */ + ssh_options_parse_config(session, NULL); + ssh_options_set(session, SSH_OPTIONS_PORT, &port); + client->state = SSH_CONNECT; } // fall through