Hello all,
I am wondering where one would submit a patch to OpenSSH cvs
version? I have written a patch that allows the user to set a timeout the
ssh clients connection attempt. I added this because many of us use ssh
in automated scripts and in some cases machines may no longer be reachable,
rather than wait you can set the timeout to say 3 seconds (-z switch).
-- Larry Cashdollar
-------------- next part --------------
--- readconf.h Sun Jun 9 16:04:03 2002
+++ ../openssh-3.5p1.modlwc/readconf.h Wed Oct 30 08:50:52 2002
@@ -100,6 +100,7 @@
Forward remote_forwards[SSH_MAX_FORWARDS_PER_DIRECTION];
int clear_forwardings;
int no_host_authentication_for_localhost;
+ int time_out;
} Options;
--- readconf.c Tue Jul 9 10:06:40 2002
+++ ../openssh-3.5p1.modlwc/readconf.c Wed Oct 30 09:32:51 2002
@@ -793,6 +793,7 @@
options->bind_address = NULL;
options->smartcard_device = NULL;
options->no_host_authentication_for_localhost = - 1;
+ options->time_out = 0;
}
/*
--- ssh.c Wed Sep 18 22:05:04 2002
+++ ../openssh-3.5p1.modlwc/ssh.c Wed Oct 30 09:47:44 2002
@@ -275,7 +275,7 @@
again:
while ((opt = getopt(ac, av,
- "1246ab:c:e:fgi:kl:m:no:p:qstvxACD:F:I:L:NPR:TVX")) != -1) {
+ "1246ab:c:e:fgi:kl:m:no:p:qstvxACD:F:I:L:NPR:TVX:z:")) != -1) {
switch (opt) {
case '1':
options.protocol = SSH_PROTO_1;
@@ -421,6 +421,9 @@
exit(1);
}
break;
+ case 'z':
+ options.time_out = atoi(optarg);
+ break;
case 'l':
options.user = optarg;
break;
--- sshconnect.c Wed Sep 18 22:05:04 2002
+++ ../openssh-3.5p1.modlwc/sshconnect.c Wed Oct 30 09:50:37 2002
@@ -236,10 +236,12 @@
{
int gaierr;
int on = 1;
- int sock = -1, attempt;
+ int sock = -1, attempt, sigfunc;
+ void timeout(void); /* Function to handle socket timeout */
char ntop[NI_MAXHOST], strport[NI_MAXSERV];
struct addrinfo hints, *ai, *aitop;
struct servent *sp;
+
/*
* Did we get only other errors than "Connection refused" (which
* should block fallback to rsh and similar), or did we get at least
@@ -299,9 +301,11 @@
if (sock < 0)
/* Any error is already output */
continue;
-
+ sigfunc = (int)signal(SIGALRM,(void *) timeout);
+ alarm(options.time_out);
if (connect(sock, ai->ai_addr, ai->ai_addrlen) >= 0) {
/* Successful connection. */
+ alarm(0);
memcpy(hostaddr, ai->ai_addr, ai->ai_addrlen);
break;
} else {
@@ -924,3 +928,18 @@
}
return (found);
}
+
+void
+timeout(void)
+{
+ /* Return to here if we get a time out after so many seconds.*/
+
+ fprintf(stderr,"Connect() timeout after %d ",options.time_out);
+
+ if (options.time_out == 1)
+ fprintf(stderr,"second.\n");
+ else
+ fprintf(stderr,"seconds.\n");
+
+exit(0);
+}