[PATCH] Added option 'RetryDelay'

Stephen Frost sfrost at snowman.net
Wed Nov 15 00:25:08 EST 2000


	Being rather aggrevated when testing at the enforced 1 second
delay between each connection attempt and the useless 1 second delay
done after all connection attempts have failed I wrote a patch to make
the number of seconds delayed between each connection attempt 
configurable.

		Stephen
-------------- next part --------------
diff -u --recursive openssh-2.3.0p1/ChangeLog openssh-2.3.0p1-new/ChangeLog
--- openssh-2.3.0p1/ChangeLog	Sun Nov  5 22:17:38 2000
+++ openssh-2.3.0p1-new/ChangeLog	Mon Nov 13 11:05:27 2000
@@ -1,3 +1,7 @@
+20001113
+ - (spf) Made sleep(1) in sshconnect.c configureable wrt time 
+   ("RetryDelay" option added)
+
 20001106
  - (djm) Use Jim's new 1.0.3 askpass in Redhat RPMs
  - (djm) Manually fix up missed diff hunks (mainly RCS idents)
diff -u --recursive openssh-2.3.0p1/readconf.c openssh-2.3.0p1-new/readconf.c
--- openssh-2.3.0p1/readconf.c	Sat Oct 14 01:23:12 2000
+++ openssh-2.3.0p1-new/readconf.c	Mon Nov 13 11:06:57 2000
@@ -98,7 +98,7 @@
 #endif
 	oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward,
 	oUser, oHost, oEscapeChar, oRhostsRSAAuthentication, oProxyCommand,
-	oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts,
+	oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts, oRetryDelay,
 	oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression,
 	oCompressionLevel, oKeepAlives, oNumberOfPasswordPrompts, oTISAuthentication,
 	oUsePrivilegedPort, oLogLevel, oCiphers, oProtocol, oIdentityFile2,
@@ -152,6 +152,7 @@
 	{ "globalknownhostsfile2", oGlobalKnownHostsFile2 },
 	{ "userknownhostsfile2", oUserKnownHostsFile2 },
 	{ "connectionattempts", oConnectionAttempts },
+	{ "retrydelay", oRetryDelay },
 	{ "batchmode", oBatchMode },
 	{ "checkhostip", oCheckHostIP },
 	{ "stricthostkeychecking", oStrictHostKeyChecking },
@@ -474,6 +475,10 @@
 		intptr = &options->connection_attempts;
 		goto parse_int;
 
+	case oRetryDelay:
+		intptr = &options->retry_delay;
+		goto parse_int;
+
 	case oCipher:
 		intptr = &options->cipher;
 		arg = strdelim(&s);
@@ -687,6 +692,7 @@
 	options->compression_level = -1;
 	options->port = -1;
 	options->connection_attempts = -1;
+	options->retry_delay = -1;
 	options->number_of_password_prompts = -1;
 	options->cipher = -1;
 	options->ciphers = NULL;
@@ -770,6 +776,8 @@
 		options->port = 0;	/* Filled in ssh_connect. */
 	if (options->connection_attempts == -1)
 		options->connection_attempts = 4;
+	if (options->retry_delay == -1)
+		options->retry_delay = 1;
 	if (options->number_of_password_prompts == -1)
 		options->number_of_password_prompts = 3;
 	/* Selected in ssh_login(). */
diff -u --recursive openssh-2.3.0p1/readconf.h openssh-2.3.0p1-new/readconf.h
--- openssh-2.3.0p1/readconf.h	Sat Oct 14 01:23:12 2000
+++ openssh-2.3.0p1-new/readconf.h	Tue Nov 14 08:01:33 2000
@@ -61,8 +61,10 @@
 	LogLevel log_level;	/* Level for logging. */
 
 	int     port;		/* Port to connect. */
-	int     connection_attempts;	/* Max attempts (seconds) before
+	int     connection_attempts;	/* Max connection attempts before
 					 * giving up */
+	int	retry_delay;	/* Number of seconds to delay between each
+				 * connection attempt */
 	int     number_of_password_prompts;	/* Max number of password
 						 * prompts. */
 	int     cipher;		/* Cipher to use. */
diff -u --recursive openssh-2.3.0p1/ssh.0 openssh-2.3.0p1-new/ssh.0
--- openssh-2.3.0p1/ssh.0	Sun Nov  5 22:25:20 2000
+++ openssh-2.3.0p1-new/ssh.0	Tue Nov 14 07:54:28 2000
@@ -538,6 +538,10 @@
              additional forwardings can be given on the command line.  Only
              the superuser can forward privileged ports.
 
+     RetryDelay
+             Specifies the number of seconds to delay between each connection
+	     attempt.
+
      RhostsAuthentication
              Specifies whether to try rhosts based authentication.  Note that
              this declaration only affects the client side and has no effect
diff -u --recursive openssh-2.3.0p1/ssh.1 openssh-2.3.0p1-new/ssh.1
--- openssh-2.3.0p1/ssh.1	Fri Oct 27 23:19:58 2000
+++ openssh-2.3.0p1-new/ssh.1	Tue Nov 14 07:55:25 2000
@@ -862,6 +862,10 @@
 Multiple forwardings may be specified, and additional
 forwardings can be given on the command line.
 Only the superuser can forward privileged ports.
+.It Cm RetryDelay
+Specifies the number of seconds to delay before attempting to
+reconnect after a failed ConnectionAttempt
+The argument must be an integer.
 .It Cm RhostsAuthentication
 Specifies whether to try rhosts based authentication.
 Note that this
diff -u --recursive openssh-2.3.0p1/ssh.c openssh-2.3.0p1-new/ssh.c
--- openssh-2.3.0p1/ssh.c	Fri Oct 27 23:19:58 2000
+++ openssh-2.3.0p1-new/ssh.c	Tue Nov 14 07:59:56 2000
@@ -620,7 +620,7 @@
 	 */
 
 	ok = ssh_connect(host, &hostaddr, options.port,
-			 options.connection_attempts,
+			 options.connection_attempts, options.retry_delay,
 			 !options.rhosts_authentication &&
 			 !options.rhosts_rsa_authentication,
 			 original_real_uid,
diff -u --recursive openssh-2.3.0p1/ssh.h openssh-2.3.0p1-new/ssh.h
--- openssh-2.3.0p1/ssh.h	Sat Oct 14 01:23:12 2000
+++ openssh-2.3.0p1-new/ssh.h	Tue Nov 14 07:51:15 2000
@@ -321,11 +321,12 @@
  * privileges if anonymous is false. Connection_attempts specifies the
  * maximum number of tries, one per second.  This returns true on success,
  * and zero on failure.  If the connection is successful, this calls
- * packet_set_connection for the connection.
+ * packet_set_connection for the connection. Retry_delay specifies the seconds
+ * to wait between connection attempts.
  */
 int
 ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
-    u_short port, int connection_attempts,
+    u_short port, int connection_attempts, int retry_delay,
     int anonymous, uid_t original_real_uid,
     const char *proxy_command);
 
diff -u --recursive openssh-2.3.0p1/sshconnect.c openssh-2.3.0p1-new/sshconnect.c
--- openssh-2.3.0p1/sshconnect.c	Sat Sep 23 02:15:57 2000
+++ openssh-2.3.0p1-new/sshconnect.c	Tue Nov 14 07:53:06 2000
@@ -180,14 +180,14 @@
  * If port is 0, the default port will be used.  If anonymous is zero,
  * a privileged port will be allocated to make the connection.
  * This requires super-user privileges if anonymous is false.
- * Connection_attempts specifies the maximum number of tries (one per
- * second).  If proxy_command is non-NULL, it specifies the command (with %h
- * and %p substituted for host and port, respectively) to use to contact
- * the daemon.
+ * Connection_attempts specifies the maximum number of tries. Retry_delay
+ * specifies the seconds to delay between attempts. If proxy_command is 
+ * non-NULL, it specifies the command (with %h * and %p substituted for 
+ * host and port, respectively) to use to contact the daemon.
  */
 int
 ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
-	    u_short port, int connection_attempts,
+	    u_short port, int connection_attempts, int retry_delay,
 	    int anonymous, uid_t original_real_uid,
 	    const char *proxy_command)
 {
@@ -284,7 +284,7 @@
 			break;	/* Successful connection. */
 
 		/* Sleep a moment before retrying. */
-		sleep(1);
+		sleep(retry_delay);
 	}
 
 	freeaddrinfo(aitop);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20001114/05360265/attachment.bin 


More information about the openssh-unix-dev mailing list