From e0ae872889c87e38892342538e8426ec4ad65f4f Mon Sep 17 00:00:00 2001 From: djm Date: Tue, 23 Apr 2002 11:09:44 +0000 Subject: [PATCH] - markus@cvs.openbsd.org 2002/04/22 21:04:52 [channels.c clientloop.c clientloop.h ssh.c] request reply (success/failure) for -R style fwd in protocol v2, depends on ordered replies. fixes http://bugzilla.mindrot.org/show_bug.cgi?id=215; ok provos@ --- ChangeLog | 5 +++++ channels.c | 4 ++-- clientloop.c | 7 ++++++- clientloop.h | 3 ++- ssh.c | 26 +++++++++++++++++++++++++- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index db04a39f..001bfd19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,11 @@ - markus@cvs.openbsd.org 2002/04/22 16:16:53 [servconf.c sshd.8 sshd_config] do not auto-enable KerberosAuthentication; ok djm@, provos@, deraadt@ + - markus@cvs.openbsd.org 2002/04/22 21:04:52 + [channels.c clientloop.c clientloop.h ssh.c] + request reply (success/failure) for -R style fwd in protocol v2, + depends on ordered replies. + fixes http://bugzilla.mindrot.org/show_bug.cgi?id=215; ok provos@ 20020421 - (tim) [entropy.c.] Portability fix for SCO Unix 3.2v4.x (SCO OSR 3.0). diff --git a/channels.c b/channels.c index 95817624..520bff82 100644 --- a/channels.c +++ b/channels.c @@ -39,7 +39,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: channels.c,v 1.172 2002/03/25 21:13:51 markus Exp $"); +RCSID("$OpenBSD: channels.c,v 1.173 2002/04/22 21:04:52 markus Exp $"); #include "ssh.h" #include "ssh1.h" @@ -2130,7 +2130,7 @@ channel_request_remote_forwarding(u_short listen_port, const char *address_to_bind = "0.0.0.0"; packet_start(SSH2_MSG_GLOBAL_REQUEST); packet_put_cstring("tcpip-forward"); - packet_put_char(0); /* boolean: want reply */ + packet_put_char(1); /* boolean: want reply */ packet_put_cstring(address_to_bind); packet_put_int(listen_port); packet_send(); diff --git a/clientloop.c b/clientloop.c index 7644ff39..15945a80 100644 --- a/clientloop.c +++ b/clientloop.c @@ -59,7 +59,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: clientloop.c,v 1.99 2002/03/21 23:07:37 markus Exp $"); +RCSID("$OpenBSD: clientloop.c,v 1.100 2002/04/22 21:04:52 markus Exp $"); #include "ssh.h" #include "ssh1.h" @@ -1314,6 +1314,7 @@ static void client_init_dispatch_20(void) { dispatch_init(&dispatch_protocol_error); + dispatch_set(SSH2_MSG_CHANNEL_CLOSE, &channel_input_oclose); dispatch_set(SSH2_MSG_CHANNEL_DATA, &channel_input_data); dispatch_set(SSH2_MSG_CHANNEL_EOF, &channel_input_ieof); @@ -1327,6 +1328,10 @@ client_init_dispatch_20(void) /* rekeying */ dispatch_set(SSH2_MSG_KEXINIT, &kex_input_kexinit); + + /* global request reply messages */ + dispatch_set(SSH2_MSG_REQUEST_FAILURE, &client_global_request_reply); + dispatch_set(SSH2_MSG_REQUEST_SUCCESS, &client_global_request_reply); } static void client_init_dispatch_13(void) diff --git a/clientloop.h b/clientloop.h index 1bc9a952..8056a40c 100644 --- a/clientloop.h +++ b/clientloop.h @@ -1,4 +1,4 @@ -/* $OpenBSD: clientloop.h,v 1.6 2001/06/26 17:27:23 markus Exp $ */ +/* $OpenBSD: clientloop.h,v 1.7 2002/04/22 21:04:52 markus Exp $ */ /* * Author: Tatu Ylonen @@ -37,3 +37,4 @@ /* Client side main loop for the interactive session. */ int client_loop(int, int, int); +void client_global_request_reply(int type, u_int32_t seq, void *ctxt); diff --git a/ssh.c b/ssh.c index c89b4135..afaf20be 100644 --- a/ssh.c +++ b/ssh.c @@ -40,7 +40,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh.c,v 1.169 2002/03/26 11:37:05 markus Exp $"); +RCSID("$OpenBSD: ssh.c,v 1.170 2002/04/22 21:04:52 markus Exp $"); #include #include @@ -146,6 +146,9 @@ Buffer command; /* Should we execute a command or invoke a subsystem? */ int subsystem_flag = 0; +/* # of replies received for global requests */ +static int client_global_request_id = 0; + /* Prints a help message to the user. This function never returns. */ static void @@ -1041,6 +1044,27 @@ client_subsystem_reply(int type, u_int32_t seq, void *ctxt) len, (u_char *)buffer_ptr(&command), id); } +void +client_global_request_reply(int type, u_int32_t seq, void *ctxt) +{ + int i; + + i = client_global_request_id++; + if (i >= options.num_remote_forwards) { + debug("client_global_request_reply: too many replies %d > %d", + i, options.num_remote_forwards); + return; + } + debug("remote forward %s for: listen %d, connect %s:%d", + type == SSH2_MSG_REQUEST_SUCCESS ? "success" : "failure", + options.remote_forwards[i].port, + options.remote_forwards[i].host, + options.remote_forwards[i].host_port); + if (type == SSH2_MSG_REQUEST_FAILURE) + log("Warning: remote port forwarding failed for listen port %d", + options.remote_forwards[i].port); +} + /* request pty/x11/agent/tcpfwd/shell for channel */ static void ssh_session2_setup(int id, void *arg) -- 2.45.1