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