Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 1 | # $OpenBSD: reexec.sh,v 1.5 2004/10/08 02:01:50 djm Exp $ |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 2 | # Placed in the Public Domain. |
3 | |||||
4 | tid="reexec tests" | ||||
5 | |||||
Darren Tucker | d98dce6 | 2005-05-26 13:43:57 +1000 | [diff] [blame] | 6 | DATA=/bin/ls${EXEEXT} |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 7 | COPY=${OBJ}/copy |
Darren Tucker | d98dce6 | 2005-05-26 13:43:57 +1000 | [diff] [blame] | 8 | SSHD_ORIG=$SSHD${EXEEXT} |
9 | SSHD_COPY=$OBJ/sshd${EXEEXT} | ||||
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 10 | |
11 | # Start a sshd and then delete it | ||||
Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 12 | start_sshd_copy () |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 13 | { |
14 | cp $SSHD_ORIG $SSHD_COPY | ||||
15 | SSHD=$SSHD_COPY | ||||
16 | start_sshd | ||||
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 17 | SSHD=$SSHD_ORIG |
18 | } | ||||
19 | |||||
Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 20 | # Do basic copy tests |
21 | copy_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 Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 36 | verbose "test config passing" |
Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 37 | |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 38 | cp $OBJ/sshd_config $OBJ/sshd_config.orig |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 39 | start_sshd |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 40 | echo "InvalidXXX=no" >> $OBJ/sshd_config |
41 | |||||
Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 42 | copy_tests |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 43 | |
Tim Rice | 722b8d1 | 2010-08-12 09:43:13 -0700 | [diff] [blame] | 44 | $SUDO kill `$SUDO cat $PIDFILE` |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 45 | rm -f $PIDFILE |
46 | |||||
47 | cp $OBJ/sshd_config.orig $OBJ/sshd_config | ||||
48 | |||||
Darren Tucker | ec1e15d | 2012-07-03 01:06:49 +1000 | [diff] [blame] | 49 | # cygwin can't fork a deleted binary |
50 | if [ "$os" != "cygwin" ]; then | ||||
51 | |||||
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 52 | verbose "test reexec fallback" |
53 | |||||
Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 54 | start_sshd_copy |
55 | rm -f $SSHD_COPY | ||||
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 56 | |
Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 57 | copy_tests |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 58 | |
Tim Rice | 722b8d1 | 2010-08-12 09:43:13 -0700 | [diff] [blame] | 59 | $SUDO kill `$SUDO cat $PIDFILE` |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 60 | rm -f $PIDFILE |
61 | |||||
62 | verbose "test reexec fallback without privsep" | ||||
63 | |||||
64 | cp $OBJ/sshd_config.orig $OBJ/sshd_config | ||||
65 | echo "UsePrivilegeSeparation=no" >> $OBJ/sshd_config | ||||
66 | |||||
Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 67 | start_sshd_copy |
68 | rm -f $SSHD_COPY | ||||
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 69 | |
Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 70 | copy_tests |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 71 | |
Tim Rice | 722b8d1 | 2010-08-12 09:43:13 -0700 | [diff] [blame] | 72 | $SUDO kill `$SUDO cat $PIDFILE` |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 73 | rm -f $PIDFILE |
74 | |||||
Darren Tucker | ec1e15d | 2012-07-03 01:06:49 +1000 | [diff] [blame] | 75 | fi |