summaryrefslogtreecommitdiff
path: root/debian/patches/ssh1-keepalive.patch
blob: 2e5fa306d8541d97b5385d70abb2009beb9b4eb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From cbbc8577950b93090171c7394bcdeb68b7c3cd0c Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@debian.org>
Date: Sun, 9 Feb 2014 16:09:51 +0000
Subject: Partial server keep-alive implementation for SSH1

Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1712
Last-Update: 2013-09-14

Patch-Name: ssh1-keepalive.patch
---
 clientloop.c | 25 +++++++++++++++----------
 ssh_config.5 |  5 ++++-
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/clientloop.c b/clientloop.c
index f9175e3..046ca8b 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -563,16 +563,21 @@ client_global_request_reply(int type, u_int32_t seq, void *ctxt)
 static void
 server_alive_check(void)
 {
-	if (packet_inc_alive_timeouts() > options.server_alive_count_max) {
-		logit("Timeout, server %s not responding.", host);
-		cleanup_exit(255);
+	if (compat20) {
+		if (packet_inc_alive_timeouts() > options.server_alive_count_max) {
+			logit("Timeout, server %s not responding.", host);
+			cleanup_exit(255);
+		}
+		packet_start(SSH2_MSG_GLOBAL_REQUEST);
+		packet_put_cstring("keepalive@openssh.com");
+		packet_put_char(1);     /* boolean: want reply */
+		packet_send();
+		/* Insert an empty placeholder to maintain ordering */
+		client_register_global_confirm(NULL, NULL);
+	} else {
+		packet_send_ignore(0);
+		packet_send();
 	}
-	packet_start(SSH2_MSG_GLOBAL_REQUEST);
-	packet_put_cstring("keepalive@openssh.com");
-	packet_put_char(1);     /* boolean: want reply */
-	packet_send();
-	/* Insert an empty placeholder to maintain ordering */
-	client_register_global_confirm(NULL, NULL);
 }
 
 /*
@@ -634,7 +639,7 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
 	 */
 
 	timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */
-	if (options.server_alive_interval > 0 && compat20) {
+	if (options.server_alive_interval > 0) {
 		timeout_secs = options.server_alive_interval;
 		server_alive_time = now + options.server_alive_interval;
 	}
diff --git a/ssh_config.5 b/ssh_config.5
index e6649ac..01f1f7f 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -1325,7 +1325,10 @@ If, for example,
 .Cm ServerAliveCountMax
 is left at the default, if the server becomes unresponsive,
 ssh will disconnect after approximately 45 seconds.
-This option applies to protocol version 2 only.
+This option applies to protocol version 2 only; in protocol version
+1 there is no mechanism to request a response from the server to the
+server alive messages, so disconnection is the responsibility of the TCP
+stack.
 .It Cm ServerAliveInterval
 Sets a timeout interval in seconds after which if no data has been received
 from the server,