Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/fs/psshfs Use sshd's pidfile instead of $! and wait fo...



details:   https://anonhg.NetBSD.org/src/rev/273270c3082a
branches:  trunk
changeset: 761939:273270c3082a
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Feb 11 13:19:46 2011 +0000

description:
Use sshd's pidfile instead of $! and wait for the pidfile to appear.
This plugs a race condition where sshd did not have a chance to
open a sucket before we attempted to connect to it.

diffstat:

 tests/fs/psshfs/sshd_config.in |  4 ++--
 tests/fs/psshfs/t_psshfs.sh    |  8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r 09b0bf998a53 -r 273270c3082a tests/fs/psshfs/sshd_config.in
--- a/tests/fs/psshfs/sshd_config.in    Fri Feb 11 12:46:41 2011 +0000
+++ b/tests/fs/psshfs/sshd_config.in    Fri Feb 11 13:19:46 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: sshd_config.in,v 1.1 2010/07/06 14:06:22 pooka Exp $
+# $NetBSD: sshd_config.in,v 1.2 2011/02/11 13:19:46 pooka Exp $
 
 # Basic settings.
 Port 10000
@@ -20,7 +20,7 @@
 StrictModes no
 
 # Some settings to allow user runs of sshd.
-PidFile @WORKDIR@/sshd.pid.2
+PidFile @WORKDIR@/sshd.pid
 Subsystem sftp @WORKDIR@/sftp-server
 UsePam no
 UsePrivilegeSeparation no
diff -r 09b0bf998a53 -r 273270c3082a tests/fs/psshfs/t_psshfs.sh
--- a/tests/fs/psshfs/t_psshfs.sh       Fri Feb 11 12:46:41 2011 +0000
+++ b/tests/fs/psshfs/t_psshfs.sh       Fri Feb 11 13:19:46 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_psshfs.sh,v 1.3 2011/01/06 07:28:32 pooka Exp $
+# $NetBSD: t_psshfs.sh,v 1.4 2011/02/11 13:19:46 pooka Exp $
 #
 # Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -80,8 +80,10 @@
        atf_check -s eq:0 -o empty -e empty chmod 400 ssh_host_key
        atf_check -s eq:0 -o empty -e empty chmod 444 ssh_host_key.pub
 
-       /usr/sbin/sshd -e -D -f ./sshd_config >sshd.log 2>&1 &
-       echo $! >sshd.pid
+       /usr/sbin/sshd -e -f ./sshd_config >sshd.log 2>&1 &
+       while [ ! -f sshd.pid ]; do
+               sleep 0.01
+       done
        echo "SSH server started (pid $(cat sshd.pid))"
 
        echo "Setting up SSH client configuration"



Home | Main Index | Thread Index | Old Index