mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-31 00:03:07 +03:00
config: Escape brackets in ProxyCommand build from ProxyJump
Missing escaping results in syntax errors in Zsh shell because of square
brackets getting interpreted as being a pattern for globbing.
Signed-off-by: Thomas Baag <libssh-git@spam.b2ag.de>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit bccb8513fa
)
This commit is contained in:
committed by
Andreas Schneider
parent
bddbe2a76d
commit
82e76a15d1
@ -491,7 +491,7 @@ ssh_config_parse_proxy_jump(ssh_session session, const char *s, bool do_parsing)
|
|||||||
if (hostname != NULL && do_parsing) {
|
if (hostname != NULL && do_parsing) {
|
||||||
char com[512] = {0};
|
char com[512] = {0};
|
||||||
|
|
||||||
rv = snprintf(com, sizeof(com), "ssh%s%s%s%s%s%s -W [%%h]:%%p %s",
|
rv = snprintf(com, sizeof(com), "ssh%s%s%s%s%s%s -W '[%%h]:%%p' %s",
|
||||||
username ? " -l " : "",
|
username ? " -l " : "",
|
||||||
username ? username : "",
|
username ? username : "",
|
||||||
port ? " -p " : "",
|
port ? " -p " : "",
|
||||||
|
@ -649,7 +649,7 @@ static void torture_config_unknown(void **state,
|
|||||||
/* test corner cases */
|
/* test corner cases */
|
||||||
_parse_config(session, file, string, SSH_OK);
|
_parse_config(session, file, string, SSH_OK);
|
||||||
assert_string_equal(session->opts.ProxyCommand,
|
assert_string_equal(session->opts.ProxyCommand,
|
||||||
"ssh -W [%h]:%p many-spaces.com");
|
"ssh -W '[%h]:%p' many-spaces.com");
|
||||||
assert_string_equal(session->opts.host, "equal.sign");
|
assert_string_equal(session->opts.host, "equal.sign");
|
||||||
|
|
||||||
ret = ssh_config_parse_file(session, "/etc/ssh/ssh_config");
|
ret = ssh_config_parse_file(session, "/etc/ssh/ssh_config");
|
||||||
@ -945,28 +945,28 @@ static void torture_config_proxyjump(void **state,
|
|||||||
torture_reset_config(session);
|
torture_reset_config(session);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "simple");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "simple");
|
||||||
_parse_config(session, file, string, SSH_OK);
|
_parse_config(session, file, string, SSH_OK);
|
||||||
assert_string_equal(session->opts.ProxyCommand, "ssh -W [%h]:%p jumpbox");
|
assert_string_equal(session->opts.ProxyCommand, "ssh -W '[%h]:%p' jumpbox");
|
||||||
|
|
||||||
/* With username */
|
/* With username */
|
||||||
torture_reset_config(session);
|
torture_reset_config(session);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "user");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "user");
|
||||||
_parse_config(session, file, string, SSH_OK);
|
_parse_config(session, file, string, SSH_OK);
|
||||||
assert_string_equal(session->opts.ProxyCommand,
|
assert_string_equal(session->opts.ProxyCommand,
|
||||||
"ssh -l user -W [%h]:%p jumpbox");
|
"ssh -l user -W '[%h]:%p' jumpbox");
|
||||||
|
|
||||||
/* With port */
|
/* With port */
|
||||||
torture_reset_config(session);
|
torture_reset_config(session);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "port");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "port");
|
||||||
_parse_config(session, file, string, SSH_OK);
|
_parse_config(session, file, string, SSH_OK);
|
||||||
assert_string_equal(session->opts.ProxyCommand,
|
assert_string_equal(session->opts.ProxyCommand,
|
||||||
"ssh -p 2222 -W [%h]:%p jumpbox");
|
"ssh -p 2222 -W '[%h]:%p' jumpbox");
|
||||||
|
|
||||||
/* Two step jump */
|
/* Two step jump */
|
||||||
torture_reset_config(session);
|
torture_reset_config(session);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "two-step");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "two-step");
|
||||||
_parse_config(session, file, string, SSH_OK);
|
_parse_config(session, file, string, SSH_OK);
|
||||||
assert_string_equal(session->opts.ProxyCommand,
|
assert_string_equal(session->opts.ProxyCommand,
|
||||||
"ssh -l u1 -p 222 -J u2@second:33 -W [%h]:%p first");
|
"ssh -l u1 -p 222 -J u2@second:33 -W '[%h]:%p' first");
|
||||||
|
|
||||||
/* none */
|
/* none */
|
||||||
torture_reset_config(session);
|
torture_reset_config(session);
|
||||||
@ -985,14 +985,14 @@ static void torture_config_proxyjump(void **state,
|
|||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "only-jump");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "only-jump");
|
||||||
_parse_config(session, file, string, SSH_OK);
|
_parse_config(session, file, string, SSH_OK);
|
||||||
assert_string_equal(session->opts.ProxyCommand,
|
assert_string_equal(session->opts.ProxyCommand,
|
||||||
"ssh -W [%h]:%p jumpbox");
|
"ssh -W '[%h]:%p' jumpbox");
|
||||||
|
|
||||||
/* IPv6 address */
|
/* IPv6 address */
|
||||||
torture_reset_config(session);
|
torture_reset_config(session);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "ipv6");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "ipv6");
|
||||||
_parse_config(session, file, string, SSH_OK);
|
_parse_config(session, file, string, SSH_OK);
|
||||||
assert_string_equal(session->opts.ProxyCommand,
|
assert_string_equal(session->opts.ProxyCommand,
|
||||||
"ssh -W [%h]:%p 2620:52:0::fed");
|
"ssh -W '[%h]:%p' 2620:52:0::fed");
|
||||||
|
|
||||||
/* In this part, we try various other config files and strings. */
|
/* In this part, we try various other config files and strings. */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user