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 | |
| 44 | $SUDO kill `cat $PIDFILE` |
| 45 | rm -f $PIDFILE |
| 46 | |
| 47 | cp $OBJ/sshd_config.orig $OBJ/sshd_config |
| 48 | |
| 49 | verbose "test reexec fallback" |
| 50 | |
Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 51 | start_sshd_copy |
| 52 | rm -f $SSHD_COPY |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 53 | |
Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 54 | copy_tests |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 55 | |
| 56 | $SUDO kill `cat $PIDFILE` |
| 57 | rm -f $PIDFILE |
| 58 | |
| 59 | verbose "test reexec fallback without privsep" |
| 60 | |
| 61 | cp $OBJ/sshd_config.orig $OBJ/sshd_config |
| 62 | echo "UsePrivilegeSeparation=no" >> $OBJ/sshd_config |
| 63 | |
Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 64 | start_sshd_copy |
| 65 | rm -f $SSHD_COPY |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 66 | |
Darren Tucker | 71b5643 | 2004-12-06 23:05:52 +1100 | [diff] [blame] | 67 | copy_tests |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 68 | |
| 69 | $SUDO kill `cat $PIDFILE` |
| 70 | rm -f $PIDFILE |
| 71 | |
Darren Tucker | 977a9d2 | 2004-06-25 13:45:18 +1000 | [diff] [blame] | 72 | |