diff options
-rw-r--r-- | usr.bin/ssh/channels.c | 21 | ||||
-rw-r--r-- | usr.bin/ssh/channels.h | 6 | ||||
-rw-r--r-- | usr.bin/ssh/serverloop.c | 5 | ||||
-rw-r--r-- | usr.bin/ssh/ssh.c | 8 |
4 files changed, 24 insertions, 16 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; } /* diff --git a/usr.bin/ssh/channels.h b/usr.bin/ssh/channels.h index 5e030a44bde..abd71904245 100644 --- a/usr.bin/ssh/channels.h +++ b/usr.bin/ssh/channels.h @@ -32,7 +32,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* RCSID("$OpenBSD: channels.h,v 1.25 2001/01/29 16:55:36 markus Exp $"); */ +/* RCSID("$OpenBSD: channels.h,v 1.26 2001/01/31 20:37:23 markus Exp $"); */ #ifndef CHANNELS_H #define CHANNELS_H @@ -206,10 +206,10 @@ char *channel_open_message(void); * 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); -void +int channel_request_forwarding(const char *listen_address, u_short listen_port, const char *host_to_connect, u_short port_to_connect, int gateway_ports, int remote_fwd); diff --git a/usr.bin/ssh/serverloop.c b/usr.bin/ssh/serverloop.c index 66a9b2bc3d9..db994316f50 100644 --- a/usr.bin/ssh/serverloop.c +++ b/usr.bin/ssh/serverloop.c @@ -35,7 +35,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: serverloop.c,v 1.43 2001/01/29 16:55:37 markus Exp $"); +RCSID("$OpenBSD: serverloop.c,v 1.44 2001/01/31 20:37:23 markus Exp $"); #include "xmalloc.h" #include "packet.h" @@ -862,12 +862,11 @@ server_input_global_request(int type, int plen, void *ctxt) packet_send_debug("Server has disabled port forwarding."); } else { /* Start listening on the port */ - channel_request_forwarding( + success = channel_request_forwarding( listen_address, listen_port, /*unspec host_to_connect*/ "<unspec host>", /*unspec port_to_connect*/ 0, options.gateway_ports, /*remote*/ 1); - success = 1; } xfree(listen_address); } diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c index 6e70e823e60..0f7d6f4d854 100644 --- a/usr.bin/ssh/ssh.c +++ b/usr.bin/ssh/ssh.c @@ -39,7 +39,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh.c,v 1.85 2001/01/29 12:36:10 djm Exp $"); +RCSID("$OpenBSD: ssh.c,v 1.86 2001/01/31 20:37:23 markus Exp $"); #include <openssl/evp.h> #include <openssl/err.h> @@ -728,19 +728,23 @@ x11_get_proto(char *proto, int proto_len, char *data, int data_len) void ssh_init_forwarding(void) { + int success = 0; int i; + /* Initiate local TCP/IP port forwardings. */ for (i = 0; i < options.num_local_forwards; i++) { debug("Connections to local port %d forwarded to remote address %.200s:%d", options.local_forwards[i].port, options.local_forwards[i].host, options.local_forwards[i].host_port); - channel_request_local_forwarding( + success += channel_request_local_forwarding( options.local_forwards[i].port, options.local_forwards[i].host, options.local_forwards[i].host_port, options.gateway_ports); } + if (i > 0 && success == 0) + error("Could not request local forwarding."); /* Initiate remote TCP/IP port forwardings. */ for (i = 0; i < options.num_remote_forwards; i++) { |