summaryrefslogtreecommitdiff
path: root/serverloop.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2003-12-17 16:27:32 +1100
committerDamien Miller <djm@mindrot.org>2003-12-17 16:27:32 +1100
commitb5820f40bf6c088b02106ef900c6608357834448 (patch)
tree459c5acd9a0fbc280ab9160fc11622b9bbca934e /serverloop.c
parent5cd9d443ef70e5c8bf8cc21bc6cc81298e18e863 (diff)
20031217
- (djm) OpenBSD CVS Sync - markus@cvs.openbsd.org 2003/12/09 15:28:43 [serverloop.c] make ClientKeepAlive work for ssh -N, too (no login shell requested). 1) send a bogus channel request if we find a channel 2) send a bogus global request if we don't have a channel ok + test beck@
Diffstat (limited to 'serverloop.c')
-rw-r--r--serverloop.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/serverloop.c b/serverloop.c
index 20255aaee..bc7cd656a 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: serverloop.c,v 1.113 2003/11/18 00:40:05 dtucker Exp $"); 38RCSID("$OpenBSD: serverloop.c,v 1.114 2003/12/09 15:28:43 markus Exp $");
39 39
40#include "xmalloc.h" 40#include "xmalloc.h"
41#include "packet.h" 41#include "packet.h"
@@ -212,26 +212,23 @@ make_packets_from_stdout_data(void)
212static void 212static void
213client_alive_check(void) 213client_alive_check(void)
214{ 214{
215 static int had_channel = 0; 215 int channel_id;
216 int id;
217
218 id = channel_find_open();
219 if (id == -1) {
220 if (!had_channel)
221 return;
222 packet_disconnect("No open channels after timeout!");
223 }
224 had_channel = 1;
225 216
226 /* timeout, check to see how many we have had */ 217 /* timeout, check to see how many we have had */
227 if (++client_alive_timeouts > options.client_alive_count_max) 218 if (++client_alive_timeouts > options.client_alive_count_max)
228 packet_disconnect("Timeout, your session not responding."); 219 packet_disconnect("Timeout, your session not responding.");
229 220
230 /* 221 /*
231 * send a bogus channel request with "wantreply", 222 * send a bogus global/channel request with "wantreply",
232 * we should get back a failure 223 * we should get back a failure
233 */ 224 */
234 channel_request_start(id, "keepalive@openssh.com", 1); 225 if ((channel_id = channel_find_open()) == -1) {
226 packet_start(SSH2_MSG_GLOBAL_REQUEST);
227 packet_put_cstring("keepalive@openssh.com");
228 packet_put_char(1); /* boolean: want reply */
229 } else {
230 channel_request_start(channel_id, "keepalive@openssh.com", 1);
231 }
235 packet_send(); 232 packet_send();
236} 233}
237 234
@@ -797,9 +794,9 @@ server_loop2(Authctxt *authctxt)
797} 794}
798 795
799static void 796static void
800server_input_channel_failure(int type, u_int32_t seq, void *ctxt) 797server_input_keep_alive(int type, u_int32_t seq, void *ctxt)
801{ 798{
802 debug("Got CHANNEL_FAILURE for keepalive"); 799 debug("Got %d/%u for keepalive", type, seq);
803 /* 800 /*
804 * reset timeout, since we got a sane answer from the client. 801 * reset timeout, since we got a sane answer from the client.
805 * even if this was generated by something other than 802 * even if this was generated by something other than
@@ -808,7 +805,6 @@ server_input_channel_failure(int type, u_int32_t seq, void *ctxt)
808 client_alive_timeouts = 0; 805 client_alive_timeouts = 0;
809} 806}
810 807
811
812static void 808static void
813server_input_stdin_data(int type, u_int32_t seq, void *ctxt) 809server_input_stdin_data(int type, u_int32_t seq, void *ctxt)
814{ 810{
@@ -1048,7 +1044,9 @@ server_init_dispatch_20(void)
1048 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust); 1044 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust);
1049 dispatch_set(SSH2_MSG_GLOBAL_REQUEST, &server_input_global_request); 1045 dispatch_set(SSH2_MSG_GLOBAL_REQUEST, &server_input_global_request);
1050 /* client_alive */ 1046 /* client_alive */
1051 dispatch_set(SSH2_MSG_CHANNEL_FAILURE, &server_input_channel_failure); 1047 dispatch_set(SSH2_MSG_CHANNEL_FAILURE, &server_input_keep_alive);
1048 dispatch_set(SSH2_MSG_REQUEST_SUCCESS, &server_input_keep_alive);
1049 dispatch_set(SSH2_MSG_REQUEST_FAILURE, &server_input_keep_alive);
1052 /* rekeying */ 1050 /* rekeying */
1053 dispatch_set(SSH2_MSG_KEXINIT, &kex_input_kexinit); 1051 dispatch_set(SSH2_MSG_KEXINIT, &kex_input_kexinit);
1054} 1052}