summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2005-03-01 21:24:33 +1100
committerDamien Miller <djm@mindrot.org>2005-03-01 21:24:33 +1100
commitf91ee4c3def4de8b4b9409f07ab26a61e535e1e6 (patch)
tree92d9f883c3c34f0d80b49a7855dcc2514798cf02 /clientloop.c
parent1717fd422f2c5691d745a7daf6908df9a6458904 (diff)
- djm@cvs.openbsd.org 2005/03/01 10:09:52
[auth-options.c channels.c channels.h clientloop.c compat.c compat.h] [misc.c misc.h readconf.c readconf.h servconf.c ssh.1 ssh.c ssh_config.5] [sshd_config.5] bz#413: allow optional specification of bind address for port forwardings. Patch originally by Dan Astorian, but worked on by several people Adds GatewayPorts=clientspecified option on server to allow remote forwards to bind to client-specified ports.
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/clientloop.c b/clientloop.c
index 033a98a5b..1e250883f 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.134 2004/11/07 00:01:46 djm Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.135 2005/03/01 10:09:52 djm Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -763,11 +763,11 @@ static void
763process_cmdline(void) 763process_cmdline(void)
764{ 764{
765 void (*handler)(int); 765 void (*handler)(int);
766 char *s, *cmd; 766 char *s, *cmd, *cancel_host;
767 u_short fwd_port, fwd_host_port;
768 char buf[1024], sfwd_port[6], sfwd_host_port[6];
769 int delete = 0; 767 int delete = 0;
770 int local = 0; 768 int local = 0;
769 u_short cancel_port;
770 Forward fwd;
771 771
772 leave_raw_mode(); 772 leave_raw_mode();
773 handler = signal(SIGINT, SIG_IGN); 773 handler = signal(SIGINT, SIG_IGN);
@@ -813,37 +813,38 @@ process_cmdline(void)
813 s++; 813 s++;
814 814
815 if (delete) { 815 if (delete) {
816 if (sscanf(s, "%5[0-9]", sfwd_host_port) != 1) { 816 cancel_port = 0;
817 logit("Bad forwarding specification."); 817 cancel_host = hpdelim(&s); /* may be NULL */
818 goto out; 818 if (s != NULL) {
819 cancel_port = a2port(s);
820 cancel_host = cleanhostname(cancel_host);
821 } else {
822 cancel_port = a2port(cancel_host);
823 cancel_host = NULL;
819 } 824 }
820 if ((fwd_host_port = a2port(sfwd_host_port)) == 0) { 825 if (cancel_port == 0) {
821 logit("Bad forwarding port(s)."); 826 logit("Bad forwarding close port");
822 goto out; 827 goto out;
823 } 828 }
824 channel_request_rforward_cancel(fwd_host_port); 829 channel_request_rforward_cancel(cancel_host, cancel_port);
825 } else { 830 } else {
826 if (sscanf(s, "%5[0-9]:%255[^:]:%5[0-9]", 831 if (!parse_forward(&fwd, s)) {
827 sfwd_port, buf, sfwd_host_port) != 3 &&
828 sscanf(s, "%5[0-9]/%255[^/]/%5[0-9]",
829 sfwd_port, buf, sfwd_host_port) != 3) {
830 logit("Bad forwarding specification."); 832 logit("Bad forwarding specification.");
831 goto out; 833 goto out;
832 } 834 }
833 if ((fwd_port = a2port(sfwd_port)) == 0 ||
834 (fwd_host_port = a2port(sfwd_host_port)) == 0) {
835 logit("Bad forwarding port(s).");
836 goto out;
837 }
838 if (local) { 835 if (local) {
839 if (channel_setup_local_fwd_listener(fwd_port, buf, 836 if (channel_setup_local_fwd_listener(fwd.listen_host,
840 fwd_host_port, options.gateway_ports) < 0) { 837 fwd.listen_port, fwd.connect_host,
838 fwd.connect_port, options.gateway_ports) < 0) {
841 logit("Port forwarding failed."); 839 logit("Port forwarding failed.");
842 goto out; 840 goto out;
843 } 841 }
844 } else 842 } else {
845 channel_request_remote_forwarding(fwd_port, buf, 843 channel_request_remote_forwarding(fwd.listen_host,
846 fwd_host_port); 844 fwd.listen_port, fwd.connect_host,
845 fwd.connect_port);
846 }
847
847 logit("Forwarding port."); 848 logit("Forwarding port.");
848 } 849 }
849 850