aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-07-11 15:15:34 +0200
committerAndreas Schneider <asn@cryptomilk.org>2013-07-26 08:42:26 +0200
commit23e0053a419b38bda11bbabe3baba9681d7f8fa1 (patch)
tree69d4d8b29ff29b01902bf624fcece146474368c3
parentb6788f369e5dadd2ead72f0a13225f6da0a48d39 (diff)
downloadlibssh-23e0053a419b38bda11bbabe3baba9681d7f8fa1.tar.gz
libssh-23e0053a419b38bda11bbabe3baba9681d7f8fa1.tar.xz
libssh-23e0053a419b38bda11bbabe3baba9681d7f8fa1.zip
BUG 103: Disable proxy command if set to 'none'.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/options.c12
-rw-r--r--tests/unittests/torture_options.c18
2 files changed, 26 insertions, 4 deletions
diff --git a/src/options.c b/src/options.c
index 398242be..4fc22dfe 100644
--- a/src/options.c
+++ b/src/options.c
@@ -655,11 +655,15 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
return -1;
} else {
SAFE_FREE(session->ProxyCommand);
- q = strdup(value);
- if (q == NULL) {
- return -1;
+ /* Setting the command to 'none' disables this option. */
+ rc = strcasecmp(value, "none");
+ if (rc != 0) {
+ q = strdup(value);
+ if (q == NULL) {
+ return -1;
+ }
+ session->ProxyCommand = q;
}
- session->ProxyCommand = q;
}
break;
default:
diff --git a/tests/unittests/torture_options.c b/tests/unittests/torture_options.c
index 3a6d9f45..2d2bfc4f 100644
--- a/tests/unittests/torture_options.c
+++ b/tests/unittests/torture_options.c
@@ -119,6 +119,23 @@ static void torture_options_set_identity(void **state) {
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 rc;
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_user, setup, teardown),
unit_test_setup_teardown(torture_options_set_identity, setup, teardown),
+ unit_test_setup_teardown(torture_options_proxycommand, setup, teardown),
};
ssh_init();