blob: 4f824a31d96165127cc169c757ba5c4533e36d24 [file] [log] [blame]
Darren Tucker71b56432004-12-06 23:05:52 +11001# $OpenBSD: reexec.sh,v 1.5 2004/10/08 02:01:50 djm Exp $
Darren Tucker977a9d22004-06-25 13:45:18 +10002# Placed in the Public Domain.
3
4tid="reexec tests"
5
Darren Tuckerd98dce62005-05-26 13:43:57 +10006DATA=/bin/ls${EXEEXT}
Darren Tucker977a9d22004-06-25 13:45:18 +10007COPY=${OBJ}/copy
Darren Tuckerd98dce62005-05-26 13:43:57 +10008SSHD_ORIG=$SSHD${EXEEXT}
9SSHD_COPY=$OBJ/sshd${EXEEXT}
Darren Tucker977a9d22004-06-25 13:45:18 +100010
11# Start a sshd and then delete it
Darren Tucker71b56432004-12-06 23:05:52 +110012start_sshd_copy ()
Darren Tucker977a9d22004-06-25 13:45:18 +100013{
14 cp $SSHD_ORIG $SSHD_COPY
15 SSHD=$SSHD_COPY
16 start_sshd
Darren Tucker977a9d22004-06-25 13:45:18 +100017 SSHD=$SSHD_ORIG
18}
19
Darren Tucker71b56432004-12-06 23:05:52 +110020# Do basic copy tests
21copy_tests ()
22{
23 rm -f ${COPY}
24 for p in 1 2; do
25 verbose "$tid: proto $p"
26 ${SSH} -nqo "Protocol=$p" -F $OBJ/ssh_config somehost \
27 cat ${DATA} > ${COPY}
28 if [ $? -ne 0 ]; then
29 fail "ssh cat $DATA failed"
30 fi
31 cmp ${DATA} ${COPY} || fail "corrupted copy"
32 rm -f ${COPY}
33 done
34}
35
Darren Tucker977a9d22004-06-25 13:45:18 +100036verbose "test config passing"
Darren Tucker71b56432004-12-06 23:05:52 +110037
Darren Tucker977a9d22004-06-25 13:45:18 +100038cp $OBJ/sshd_config $OBJ/sshd_config.orig
Darren Tucker977a9d22004-06-25 13:45:18 +100039start_sshd
Darren Tucker977a9d22004-06-25 13:45:18 +100040echo "InvalidXXX=no" >> $OBJ/sshd_config
41
Darren Tucker71b56432004-12-06 23:05:52 +110042copy_tests
Darren Tucker977a9d22004-06-25 13:45:18 +100043
44$SUDO kill `cat $PIDFILE`
45rm -f $PIDFILE
46
47cp $OBJ/sshd_config.orig $OBJ/sshd_config
48
49verbose "test reexec fallback"
50
Darren Tucker71b56432004-12-06 23:05:52 +110051start_sshd_copy
52rm -f $SSHD_COPY
Darren Tucker977a9d22004-06-25 13:45:18 +100053
Darren Tucker71b56432004-12-06 23:05:52 +110054copy_tests
Darren Tucker977a9d22004-06-25 13:45:18 +100055
56$SUDO kill `cat $PIDFILE`
57rm -f $PIDFILE
58
59verbose "test reexec fallback without privsep"
60
61cp $OBJ/sshd_config.orig $OBJ/sshd_config
62echo "UsePrivilegeSeparation=no" >> $OBJ/sshd_config
63
Darren Tucker71b56432004-12-06 23:05:52 +110064start_sshd_copy
65rm -f $SSHD_COPY
Darren Tucker977a9d22004-06-25 13:45:18 +100066
Darren Tucker71b56432004-12-06 23:05:52 +110067copy_tests
Darren Tucker977a9d22004-06-25 13:45:18 +100068
69$SUDO kill `cat $PIDFILE`
70rm -f $PIDFILE
71
Darren Tucker977a9d22004-06-25 13:45:18 +100072