[Bug 1752] New: Test port not available during make tests

bugzilla-daemon at bugzilla.mindrot.org bugzilla-daemon at bugzilla.mindrot.org
Sat Apr 10 03:39:03 EST 2010


https://bugzilla.mindrot.org/show_bug.cgi?id=1752

           Summary: Test port not available during make tests
           Product: Portable OpenSSH
           Version: 5.4p1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Build system
        AssignedTo: unassigned-bugs at mindrot.org
        ReportedBy: petesea at bigfoot.com


While building the latest OpenSSH from CVS (2010-04-09), "make tests"
fails with the error "no sshd running on port 4242".  The real cause in
my case is that something is already running on port 4242 (the Juniper
Network Connect client).

It would be nice if the error message were a bit more helpful, eg:

   no sshd running on port 4242, try setting $TEST_SSH_PORT to a
different port

To go a step further, it might be nice if the code used to set the port
was a bit more resilient, with an error message more informative.

Maybe the code in test-exec.sh:

  if [ ! -z "$TEST_SSH_PORT" ]; then
    PORT="$TEST_SSH_PORT"
  else
    PORT=4242
  fi

could be something similar to:

  if [ ! -z "$TEST_SSH_PORT" ]; then
    PORT="$TEST_SSH_PORT"
  else
    first_port=4200
    last_port=4300

    test_port=$first_port
    while [ "$test_port" -le "$last_port" ]; do
      netstat -na | grep "[:.]$test_port " >/dev/null 2>&1 || {
PORT=$test_port; break; }
      test_port=`expr $test_port + 1`
    done

    if [ -z "$PORT" ]; then
      echo "Unable to find usable test port between $first_port and
$last_port.  Define \$TEST_SSH_PORT."
      exit 2
    fi
  fi

I realize the 'netstat | grep' command above may not be the best, most
portable way to look for an available port, but the idea is the same...
ie. run something that checks to see if the requested port is available
or not.  FYI, I did run the above code on several boxes (solaris, hpux,
macosx, fedora, redhat, centos, cygwin) and it seemed to work fine.

Another possible way to check would be to run sshd -D and look at the
output.  In my case it says:

  Bind to port 4242 on 127.0.0.1 failed: Address already in use.
  Cannot bind any address.

Which (again in my particular case), would have been a much more
helpful error message then "no sshd running on port 4242".

Unfortunately, with this approach the sshd command would need to be
killed/terminated somehow.

Or... maybe the sshd -t (or -T) option could be enhanced (or a new
option created) that checks to see if the port is available, but
doesn't actually start a server.  I suspect this really means it would
try to bind to that port and then just close if it works, otherwise
report the error. Problem is, on some systems I believe it can take a
while before a port can be reused... so a passive check may be better.

-- 
Configure bugmail: https://bugzilla.mindrot.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list