SHA256
8
0
forked from pool/libssh
Files
libssh/fix-proxy-command-none.diff
Stephan Kulow 753c926479 Accepting request 184375 from network:synchronization:files
Add two patches (which will be in libssh 0.5.5) to properly handle 
ProxyCommand parsing in ssh configuration files:

- Add fix-proxycomand-parsing1.diff: fix ProxyCommand parsing in 
  libssh (upstream libssh bug 103)
- Add fix-proxy-command-none.diff: fix ProxyCommand when it is
  "none" (upstream libssh bug 103) (forwarded request 184365 from luca_b)

OBS-URL: https://build.opensuse.org/request/show/184375
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/libssh?expand=0&rev=27
2013-07-27 13:47:28 +00:00

51 lines
1.5 KiB
Diff

diff -rupN a/src/options.c b/src/options.c
--- a/options.c 2013-01-22 11:38:30.000000000 +0100
+++ b/src/options.c 2013-07-15 09:45:28.000000000 +0200
@@ -655,11 +655,15 @@ int ssh_options_set(ssh_session session,
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:
--- a/tests/unittests/torture_options.c.orig 2013-07-25 22:06:19.016024956 +0200
+++ b/tests/unittests/torture_options.c 2013-07-25 22:11:28.941507282 +0200
@@ -119,6 +119,24 @@
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->opts.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_null(session->opts.ProxyCommand);
+}
+
+
int torture_run_tests(void) {
int rc;
const UnitTest tests[] = {