blob: 9464eb699ba790ac13011fbabbc331fcb8de5302 [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
Tim Rice722b8d12010-08-12 09:43:13 -070044$SUDO kill `$SUDO cat $PIDFILE`
Darren Tucker977a9d22004-06-25 13:45:18 +100045rm -f $PIDFILE
46
47cp $OBJ/sshd_config.orig $OBJ/sshd_config
48
Darren Tuckerec1e15d2012-07-03 01:06:49 +100049# cygwin can't fork a deleted binary
50if [ "$os" != "cygwin" ]; then
51
Darren Tucker977a9d22004-06-25 13:45:18 +100052verbose "test reexec fallback"
53
Darren Tucker71b56432004-12-06 23:05:52 +110054start_sshd_copy
55rm -f $SSHD_COPY
Darren Tucker977a9d22004-06-25 13:45:18 +100056
Darren Tucker71b56432004-12-06 23:05:52 +110057copy_tests
Darren Tucker977a9d22004-06-25 13:45:18 +100058
Tim Rice722b8d12010-08-12 09:43:13 -070059$SUDO kill `$SUDO cat $PIDFILE`
Darren Tucker977a9d22004-06-25 13:45:18 +100060rm -f $PIDFILE
61
62verbose "test reexec fallback without privsep"
63
64cp $OBJ/sshd_config.orig $OBJ/sshd_config
65echo "UsePrivilegeSeparation=no" >> $OBJ/sshd_config
66
Darren Tucker71b56432004-12-06 23:05:52 +110067start_sshd_copy
68rm -f $SSHD_COPY
Darren Tucker977a9d22004-06-25 13:45:18 +100069
Darren Tucker71b56432004-12-06 23:05:52 +110070copy_tests
Darren Tucker977a9d22004-06-25 13:45:18 +100071
Tim Rice722b8d12010-08-12 09:43:13 -070072$SUDO kill `$SUDO cat $PIDFILE`
Darren Tucker977a9d22004-06-25 13:45:18 +100073rm -f $PIDFILE
74
Darren Tuckerec1e15d2012-07-03 01:06:49 +100075fi