www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-apps/2001/11/15/16:40:13

Mailing-List: contact cygwin-apps-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-apps-owner AT sourceware DOT cygnus DOT com
List-Subscribe: <mailto:cygwin-apps-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-apps/>
List-Post: <mailto:cygwin-apps AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-apps-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/lists.html#faqs>
Delivered-To: mailing list cygwin-apps AT sources DOT redhat DOT com
Date: 15 Nov 2001 16:39:59 -0500
Message-ID: <20011115213959.6226.qmail@lizard.curl.com>
From: Jonathan Kamens <jik AT curl DOT com>
To: cygwin-apps AT cygwin DOT com
Subject: Fixing openssh to avoid occasional spurious connection failures

As I just noted in
<URL:http://www.cygwin.com/ml/cygwin-developers/2001-11/msg00080.html>,
ssh connections from Cygwin can occasionally fail because a winsock
bug causes the connection to be assigned a local port number which is
already in use.

The simplest workaround for this problem would be to put a default
"ConnectionAttempts 4" setting in the ssh_config that gets generated
by ssh-host-config.

The next simplest workaround would be to get the OpenSSH maintainers
to apply this patch:

  Index: readconf.c
  ===================================================================
  RCS file: /cvs/openssh_cvs/readconf.c,v
  retrieving revision 1.66
  diff -u -r1.66 readconf.c
  --- readconf.c	2001/10/03 17:39:39	1.66
  +++ readconf.c	2001/11/15 21:27:55
  @@ -870,7 +870,11 @@
          if (options->port == -1)
                  options->port = 0;	/* Filled in ssh_connect. */
          if (options->connection_attempts == -1)
  +#ifdef HAVE_CYGWIN
  +		options->connection_attempts = 4;
  +#else
                  options->connection_attempts = 1;
  +#endif
          if (options->number_of_password_prompts == -1)
                  options->number_of_password_prompts = 3;
          /* Selected in ssh_login(). */

The advantage of this fix is that it will work for people who already
have an ssh_config file.

The disadvantage of either of the two fixes given above is that
although the connection will succeed, it'll also print out warnings of
the form "ssh: connect to address XXX.XXX.XXX.XXX port 22: Address
already in use" before it succeeds.  Something like this could be used
to fix that:

  Index: sshconnect.c
  ===================================================================
  RCS file: /cvs/openssh_cvs/sshconnect.c,v
  retrieving revision 1.80
  diff -u -r1.80 sshconnect.c
  --- sshconnect.c	2001/10/10 05:07:45	1.80
  +++ sshconnect.c	2001/11/15 21:39:02
  @@ -330,6 +330,10 @@
                          } else {
                                  if (errno == ECONNREFUSED)
                                          full_failure = 0;
  +#ifdef HAVE_CYGWIN
  +                                if ((errno != EADDRINUSE) ||
  +                                    (attempt == connection_attempts - 1))
  +#endif
                                  log("ssh: connect to address %s port %s: %s",
                                      sockaddr_ntop(ai->ai_addr), strport,
                                      strerror(errno));

Jonathan Kamens

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019