diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2001-01-31 20:37:24 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2001-01-31 20:37:24 +0000 |
commit | cdaaf935b299d374083223fdf61c085686e75651 (patch) | |
tree | 5427d6c4abf4bc5e15dbb91b6c7760041a4ade55 /usr.bin/ssh/channels.c | |
parent | f1da71e6e5d4a285ef07cad59d822a5cd0ee6689 (diff) |
do not disconnect if local port forwarding fails, e.g. if port is already in use
Diffstat (limited to 'usr.bin/ssh/channels.c')
-rw-r--r-- | usr.bin/ssh/channels.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/usr.bin/ssh/channels.c b/usr.bin/ssh/channels.c index ec196e9c304..4ffc84ce59b 100644 --- a/usr.bin/ssh/channels.c +++ b/usr.bin/ssh/channels.c @@ -40,7 +40,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: channels.c,v 1.86 2001/01/31 19:26:19 markus Exp $"); +RCSID("$OpenBSD: channels.c,v 1.87 2001/01/31 20:37:22 markus Exp $"); #include <openssl/rsa.h> #include <openssl/dsa.h> @@ -1531,11 +1531,11 @@ channel_open_message() * Initiate forwarding of connections to local port "port" through the secure * channel to host:port from remote side. */ -void +int channel_request_local_forwarding(u_short listen_port, const char *host_to_connect, u_short port_to_connect, int gateway_ports) { - channel_request_forwarding( + return channel_request_forwarding( NULL, listen_port, host_to_connect, port_to_connect, gateway_ports, /*remote_fwd*/ 0); @@ -1545,7 +1545,7 @@ channel_request_local_forwarding(u_short listen_port, const char *host_to_connec * If 'remote_fwd' is true we have a '-R style' listener for protocol 2 * (SSH_CHANNEL_RPORT_LISTENER). */ -void +int channel_request_forwarding( const char *listen_address, u_short listen_port, const char *host_to_connect, u_short port_to_connect, @@ -1557,6 +1557,8 @@ channel_request_forwarding( const char *host; struct linger linger; + success = 0; + if (remote_fwd) { host = listen_address; ctype = SSH_CHANNEL_RPORT_LISTENER; @@ -1565,8 +1567,10 @@ channel_request_forwarding( ctype =SSH_CHANNEL_PORT_LISTENER; } - if (strlen(host) > sizeof(channels[0].path) - 1) - packet_disconnect("Forward host name too long."); + if (strlen(host) > sizeof(channels[0].path) - 1) { + error("Forward host name too long."); + return success; + } /* XXX listen_address is currently ignored */ /* @@ -1581,7 +1585,6 @@ channel_request_forwarding( if (getaddrinfo(NULL, strport, &hints, &aitop) != 0) packet_disconnect("getaddrinfo: fatal error"); - success = 0; for (ai = aitop; ai; ai = ai->ai_next) { if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) continue; @@ -1630,8 +1633,10 @@ channel_request_forwarding( success = 1; } if (success == 0) - packet_disconnect("cannot listen port: %d", listen_port); /*XXX ?disconnect? */ + error("channel_request_forwarding: cannot listen to port: %d", + listen_port); freeaddrinfo(aitop); + return success; } /* |