do not choke at end of test suite if no sshd was ever launched.
[monkeysphere.git] / tests / basic
index 46ba63c1cda77e439f8dfaf9e741cc9d48c53976..393bcc22845e50b9cf61e65a83aa386322f17490 100755 (executable)
@@ -23,6 +23,7 @@ launch_sshd() {
     socat EXEC:"/usr/sbin/sshd -f ${SSHD_CONFIG} -i -D -e" "UNIX-LISTEN:${SOCKET}" 2> "$TEMPDIR"/sshd.log &
     export SSHD_PID=$!
 
+    # wait until the socket is created before continuing
     while [ ! -S "$SOCKET" ] ; do
        sleep 1
     done
@@ -42,7 +43,7 @@ failed_cleanup() {
 }
 
 cleanup() {
-    if ( ps "$SSHD_PID" >/dev/null ) ; then 
+    if [ "$SSHD_PID" ] && ( ps "$SSHD_PID" >/dev/null ) ; then 
        echo "### stopping still-running sshd..."
        kill "$SSHD_PID"
     fi
@@ -81,6 +82,7 @@ export MONKEYSPHERE_CHECK_KEYSERVER=false
 
 export SSHD_CONFIG="$TEMPDIR"/sshd_config
 export SOCKET="$TEMPDIR"/ssh-socket
+export SSHD_PID=
 
 # copy in admin and testuser home to tmp
 echo "### copying admin and testuser homes..."
@@ -89,6 +91,7 @@ cp -a "$TESTDIR"/home/testuser "$TEMPDIR"/
 
 cat <<EOF >> "$TEMPDIR"/testuser/.ssh/config
 UserKnownHostsFile $TEMPDIR/testuser/.ssh/known_hosts
+IdentityFile $TEMPDIR/testuser/.ssh/no-such-identity
 ProxyCommand $TEMPDIR/testuser/.ssh/proxy-command %h %p $SOCKET
 EOF
 
@@ -187,8 +190,6 @@ launch_sshd
 
 # and make sure the user can no longer connect
 echo "### testuser attempting to connect to sshd socket..."
-# FIXME: this prompts for the passphrase for the default identity
-# file.  how can this be avoided?
 ssh_test || SSH_RETURN="$?"
 if [ "$SSH_RETURN" != '255' ] ; then
     exit