blob: 433573f0642465d757aa719dce7d613efee597ad [file] [log] [blame]
Darren Tucker05b5e512013-05-17 20:41:07 +10001# $OpenBSD: reexec.sh,v 1.7 2013/05/17 10:23:52 dtucker Exp $
Darren Tucker977a9d22004-06-25 13:45:18 +10002# Placed in the Public Domain.
3
4tid="reexec tests"
5
Darren Tucker59d928d2013-05-17 15:32:29 +10006SSHD_ORIG=$SSHD
7SSHD_COPY=$OBJ/sshd
Darren Tucker977a9d22004-06-25 13:45:18 +10008
9# Start a sshd and then delete it
Darren Tucker71b56432004-12-06 23:05:52 +110010start_sshd_copy ()
Darren Tucker977a9d22004-06-25 13:45:18 +100011{
12 cp $SSHD_ORIG $SSHD_COPY
13 SSHD=$SSHD_COPY
14 start_sshd
Darren Tucker977a9d22004-06-25 13:45:18 +100015 SSHD=$SSHD_ORIG
16}
17
Darren Tucker71b56432004-12-06 23:05:52 +110018# Do basic copy tests
19copy_tests ()
20{
21 rm -f ${COPY}
22 for p in 1 2; do
23 verbose "$tid: proto $p"
24 ${SSH} -nqo "Protocol=$p" -F $OBJ/ssh_config somehost \
25 cat ${DATA} > ${COPY}
26 if [ $? -ne 0 ]; then
27 fail "ssh cat $DATA failed"
28 fi
29 cmp ${DATA} ${COPY} || fail "corrupted copy"
30 rm -f ${COPY}
31 done
32}
33
Darren Tucker977a9d22004-06-25 13:45:18 +100034verbose "test config passing"
Darren Tucker71b56432004-12-06 23:05:52 +110035
Darren Tucker977a9d22004-06-25 13:45:18 +100036cp $OBJ/sshd_config $OBJ/sshd_config.orig
Darren Tucker977a9d22004-06-25 13:45:18 +100037start_sshd
Darren Tucker977a9d22004-06-25 13:45:18 +100038echo "InvalidXXX=no" >> $OBJ/sshd_config
39
Darren Tucker71b56432004-12-06 23:05:52 +110040copy_tests
Darren Tucker977a9d22004-06-25 13:45:18 +100041
Tim Rice722b8d12010-08-12 09:43:13 -070042$SUDO kill `$SUDO cat $PIDFILE`
Darren Tucker977a9d22004-06-25 13:45:18 +100043rm -f $PIDFILE
44
45cp $OBJ/sshd_config.orig $OBJ/sshd_config
46
Darren Tuckerec1e15d2012-07-03 01:06:49 +100047# cygwin can't fork a deleted binary
48if [ "$os" != "cygwin" ]; then
49
Darren Tucker977a9d22004-06-25 13:45:18 +100050verbose "test reexec fallback"
51
Darren Tucker71b56432004-12-06 23:05:52 +110052start_sshd_copy
53rm -f $SSHD_COPY
Darren Tucker977a9d22004-06-25 13:45:18 +100054
Darren Tucker71b56432004-12-06 23:05:52 +110055copy_tests
Darren Tucker977a9d22004-06-25 13:45:18 +100056
Tim Rice722b8d12010-08-12 09:43:13 -070057$SUDO kill `$SUDO cat $PIDFILE`
Darren Tucker977a9d22004-06-25 13:45:18 +100058rm -f $PIDFILE
59
60verbose "test reexec fallback without privsep"
61
62cp $OBJ/sshd_config.orig $OBJ/sshd_config
63echo "UsePrivilegeSeparation=no" >> $OBJ/sshd_config
64
Darren Tucker71b56432004-12-06 23:05:52 +110065start_sshd_copy
66rm -f $SSHD_COPY
Darren Tucker977a9d22004-06-25 13:45:18 +100067
Darren Tucker71b56432004-12-06 23:05:52 +110068copy_tests
Darren Tucker977a9d22004-06-25 13:45:18 +100069
Tim Rice722b8d12010-08-12 09:43:13 -070070$SUDO kill `$SUDO cat $PIDFILE`
Darren Tucker977a9d22004-06-25 13:45:18 +100071rm -f $PIDFILE
72
Darren Tuckerec1e15d2012-07-03 01:06:49 +100073fi