summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/usr.bin/ssh/Makefile5
-rw-r--r--regress/usr.bin/ssh/reexec.sh75
-rw-r--r--regress/usr.bin/ssh/test-exec.sh26
3 files changed, 103 insertions, 3 deletions
diff --git a/regress/usr.bin/ssh/Makefile b/regress/usr.bin/ssh/Makefile
index 09fbe21389c..4acda7c60a9 100644
--- a/regress/usr.bin/ssh/Makefile
+++ b/regress/usr.bin/ssh/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.30 2004/06/13 15:04:08 djm Exp $
+# $OpenBSD: Makefile,v 1.31 2004/06/24 19:32:00 djm Exp $
REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7
@@ -34,7 +34,8 @@ LTESTS= connect \
reconfigure \
dynamic-forward \
forwarding \
- multiplex
+ multiplex \
+ reexec
USER!= id -un
CLEANFILES+= authorized_keys_${USER} known_hosts pidfile \
diff --git a/regress/usr.bin/ssh/reexec.sh b/regress/usr.bin/ssh/reexec.sh
new file mode 100644
index 00000000000..c5ee58b26ff
--- /dev/null
+++ b/regress/usr.bin/ssh/reexec.sh
@@ -0,0 +1,75 @@
+# $OpenBSD: reexec.sh,v 1.1 2004/06/24 19:32:00 djm Exp $
+# Placed in the Public Domain.
+
+tid="reexec tests"
+
+DATA=/bin/ls
+COPY=${OBJ}/copy
+
+verbose "test config passing"
+cp $OBJ/sshd_config $OBJ/sshd_config.orig
+
+start_sshd
+
+echo "InvalidXXX=no" >> $OBJ/sshd_config
+
+rm -f ${COPY}
+for p in 1 2; do
+ verbose "$tid: proto $p"
+ ${SSH} -nqo "Protocol=$p" -F $OBJ/ssh_config somehost \
+ cat ${DATA} > ${COPY}
+ if [ $? -ne 0 ]; then
+ fail "ssh cat $DATA failed"
+ fi
+ cmp ${DATA} ${COPY} || fail "corrupted copy"
+ rm -f ${COPY}
+done
+
+$SUDO kill `cat $PIDFILE`
+rm -f $PIDFILE
+
+cp $OBJ/sshd_config.orig $OBJ/sshd_config
+
+verbose "test reexec fallback"
+
+start_sshd_copy_zap
+
+rm -f ${COPY}
+for p in 1 2; do
+ verbose "$tid: proto $p"
+ ${SSH} -nqo "Protocol=$p" -F $OBJ/ssh_config somehost \
+ cat ${DATA} > ${COPY}
+ if [ $? -ne 0 ]; then
+ fail "ssh cat $DATA failed"
+ fi
+ cmp ${DATA} ${COPY} || fail "corrupted copy"
+ rm -f ${COPY}
+done
+
+$SUDO kill `cat $PIDFILE`
+rm -f $PIDFILE
+
+verbose "test reexec fallback without privsep"
+
+cp $OBJ/sshd_config.orig $OBJ/sshd_config
+echo "UsePrivilegeSeparation=no" >> $OBJ/sshd_config
+
+start_sshd_copy_zap
+
+rm -f ${COPY}
+for p in 1 2; do
+ verbose "$tid: proto $p"
+ ${SSH} -nqo "Protocol=$p" -F $OBJ/ssh_config somehost \
+ cat ${DATA} > ${COPY}
+ if [ $? -ne 0 ]; then
+ fail "ssh cat $DATA failed"
+ fi
+ cmp ${DATA} ${COPY} || fail "corrupted copy"
+ rm -f ${COPY}
+done
+
+$SUDO kill `cat $PIDFILE`
+rm -f $PIDFILE
+
+cp $OBJ/sshd_config.orig $OBJ/sshd_config
+
diff --git a/regress/usr.bin/ssh/test-exec.sh b/regress/usr.bin/ssh/test-exec.sh
index 9d1b1734ed9..b859521cd35 100644
--- a/regress/usr.bin/ssh/test-exec.sh
+++ b/regress/usr.bin/ssh/test-exec.sh
@@ -1,4 +1,4 @@
-# $OpenBSD: test-exec.sh,v 1.21 2004/06/22 22:55:56 dtucker Exp $
+# $OpenBSD: test-exec.sh,v 1.22 2004/06/24 19:32:00 djm Exp $
# Placed in the Public Domain.
USER=`id -un`
@@ -76,6 +76,9 @@ if [ "x$TEST_SSH_SCP" != "x" ]; then
SCP="${TEST_SSH_SCP}"
fi
+# Path to sshd must be absolute for rexec
+SSHD=`which sshd`
+
# these should be used in tests
export SSH SSHD SSHAGENT SSHADD SSHKEYGEN SSHKEYSCAN SFTP SFTPSERVER SCP
#echo $SSH $SSHD $SSHAGENT $SSHADD $SSHKEYGEN $SSHKEYSCAN $SFTP $SFTPSERVER $SCP
@@ -233,6 +236,27 @@ start_sshd ()
test -f $PIDFILE || fatal "no sshd running on port $PORT"
}
+# Start a sshd and then delete it
+start_sshd_copy_zap ()
+{
+ cp ${SSHD} $OBJ/sshd.copy
+ SSHD_CPY=`which $OBJ/sshd.copy`
+
+ # start sshd
+ $SUDO $SSHD_CPY -f $OBJ/sshd_config -t || fatal "sshd_config broken"
+ $SUDO $SSHD_CPY -f $OBJ/sshd_config
+
+ trace "wait for sshd"
+ i=0;
+ while [ ! -f $PIDFILE -a $i -lt 5 ]; do
+ i=`expr $i + 1`
+ sleep $i
+ done
+
+ test -f $PIDFILE || fatal "no sshd running on port $PORT"
+ rm -f $OBJ/sshd.copy
+}
+
# source test body
. $SCRIPT