1# $OpenBSD: reexec.sh,v 1.13 2023/01/19 07:53:45 dtucker Exp $ 2# Placed in the Public Domain. 3 4tid="reexec tests" 5 6SSHD_ORIG=$SSHD 7SSHD_COPY=$OBJ/sshd 8 9# Start a sshd and then delete it 10start_sshd_copy () 11{ 12 if [ -r "$SSHD_ORIG" ]; then 13 cp "$SSHD_ORIG" "$SSHD_COPY" 14 elif [ -z "$SUDO" ] || ! $SUDO cp "$SSHD_ORIG" "$SSHD_COPY"; then 15 skip "Cannot copy sshd." 16 fi 17 SSHD=$SSHD_COPY 18 start_sshd 19 SSHD=$SSHD_ORIG 20} 21 22# Do basic copy tests 23copy_tests () 24{ 25 rm -f ${COPY} 26 ${SSH} -nq -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} 34 35verbose "test config passing" 36 37cp $OBJ/sshd_config $OBJ/sshd_config.orig 38start_sshd 39echo "InvalidXXX=no" >> $OBJ/sshd_config 40 41copy_tests 42 43stop_sshd 44 45cp $OBJ/sshd_config.orig $OBJ/sshd_config 46 47verbose "test reexec fallback" 48 49start_sshd_copy 50$SUDO rm -f $SSHD_COPY 51 52copy_tests 53 54stop_sshd 55