1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-05 20:55:46 +03:00

BUG 103: Disable proxy command if set to 'none'.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Andreas Schneider
2013-07-11 15:15:34 +02:00
parent b6788f369e
commit 23e0053a41
2 changed files with 26 additions and 4 deletions

View File

@@ -655,11 +655,15 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
return -1; return -1;
} else { } else {
SAFE_FREE(session->ProxyCommand); SAFE_FREE(session->ProxyCommand);
q = strdup(value); /* Setting the command to 'none' disables this option. */
if (q == NULL) { rc = strcasecmp(value, "none");
return -1; if (rc != 0) {
q = strdup(value);
if (q == NULL) {
return -1;
}
session->ProxyCommand = q;
} }
session->ProxyCommand = q;
} }
break; break;
default: default:

View File

@@ -119,6 +119,23 @@ static void torture_options_set_identity(void **state) {
assert_string_equal(session->identity->root->next->data, "identity1"); assert_string_equal(session->identity->root->next->data, "identity1");
} }
static void torture_options_proxycommand(void **state) {
ssh_session session = *state;
int rc;
/* Enable ProxyCommand */
rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, "ssh -q -A -X -W %h:%p JUMPHOST");
assert_int_equal(rc, 0);
assert_string_equal(session->ProxyCommand, "ssh -q -A -X -W %h:%p JUMPHOST");
/* Disable ProxyCommand */
rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, "none");
assert_int_equal(rc, 0);
assert_true(session->ProxyCommand == NULL);
}
int torture_run_tests(void) { int torture_run_tests(void) {
int rc; int rc;
const UnitTest tests[] = { const UnitTest tests[] = {
@@ -127,6 +144,7 @@ int torture_run_tests(void) {
unit_test_setup_teardown(torture_options_set_fd, setup, teardown), unit_test_setup_teardown(torture_options_set_fd, setup, teardown),
unit_test_setup_teardown(torture_options_set_user, setup, teardown), unit_test_setup_teardown(torture_options_set_user, setup, teardown),
unit_test_setup_teardown(torture_options_set_identity, setup, teardown), unit_test_setup_teardown(torture_options_set_identity, setup, teardown),
unit_test_setup_teardown(torture_options_proxycommand, setup, teardown),
}; };
ssh_init(); ssh_init();