diff options
author | Damien Miller <djm@mindrot.org> | 2003-12-17 16:27:32 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2003-12-17 16:27:32 +1100 |
commit | b5820f40bf6c088b02106ef900c6608357834448 (patch) | |
tree | 459c5acd9a0fbc280ab9160fc11622b9bbca934e | |
parent | 5cd9d443ef70e5c8bf8cc21bc6cc81298e18e863 (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@
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | serverloop.c | 32 |
2 files changed, 25 insertions, 18 deletions
@@ -1,3 +1,12 @@ | |||
1 | 20031217 | ||
2 | - (djm) OpenBSD CVS Sync | ||
3 | - markus@cvs.openbsd.org 2003/12/09 15:28:43 | ||
4 | [serverloop.c] | ||
5 | make ClientKeepAlive work for ssh -N, too (no login shell requested). | ||
6 | 1) send a bogus channel request if we find a channel | ||
7 | 2) send a bogus global request if we don't have a channel | ||
8 | ok + test beck@ | ||
9 | |||
1 | 20031209 | 10 | 20031209 |
2 | - (dtucker) OpenBSD CVS Sync | 11 | - (dtucker) OpenBSD CVS Sync |
3 | - matthieu@cvs.openbsd.org 2003/11/25 23:10:08 | 12 | - matthieu@cvs.openbsd.org 2003/11/25 23:10:08 |
@@ -1566,4 +1575,4 @@ | |||
1566 | - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. | 1575 | - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. |
1567 | Report from murple@murple.net, diagnosis from dtucker@zip.com.au | 1576 | Report from murple@murple.net, diagnosis from dtucker@zip.com.au |
1568 | 1577 | ||
1569 | $Id: ChangeLog,v 1.3139 2003/12/09 13:54:38 dtucker Exp $ | 1578 | $Id: ChangeLog,v 1.3140 2003/12/17 05:27:32 djm Exp $ |
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" |
38 | RCSID("$OpenBSD: serverloop.c,v 1.113 2003/11/18 00:40:05 dtucker Exp $"); | 38 | RCSID("$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) | |||
212 | static void | 212 | static void |
213 | client_alive_check(void) | 213 | client_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 | ||
799 | static void | 796 | static void |
800 | server_input_channel_failure(int type, u_int32_t seq, void *ctxt) | 797 | server_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 | |||
812 | static void | 808 | static void |
813 | server_input_stdin_data(int type, u_int32_t seq, void *ctxt) | 809 | server_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 | } |