2023-01-19 07:53:45 +00:00
|
|
|
# $OpenBSD: reexec.sh,v 1.13 2023/01/19 07:53:45 dtucker Exp $
|
2004-06-25 03:45:18 +00:00
|
|
|
# Placed in the Public Domain.
|
|
|
|
|
|
|
|
tid="reexec tests"
|
|
|
|
|
2013-05-17 05:32:29 +00:00
|
|
|
SSHD_ORIG=$SSHD
|
|
|
|
SSHD_COPY=$OBJ/sshd
|
2004-06-25 03:45:18 +00:00
|
|
|
|
|
|
|
# Start a sshd and then delete it
|
2004-12-06 12:05:52 +00:00
|
|
|
start_sshd_copy ()
|
2004-06-25 03:45:18 +00:00
|
|
|
{
|
2020-05-14 02:22:09 +00:00
|
|
|
# NB. prefer ln to cp here. On some OSX 19.4 configurations,
|
|
|
|
# djm has seen failure after fork() when the executable image
|
|
|
|
# has been removed from the filesystem.
|
|
|
|
ln $SSHD_ORIG $SSHD_COPY || cp $SSHD_ORIG $SSHD_COPY
|
2004-06-25 03:45:18 +00:00
|
|
|
SSHD=$SSHD_COPY
|
|
|
|
start_sshd
|
|
|
|
SSHD=$SSHD_ORIG
|
|
|
|
}
|
|
|
|
|
2004-12-06 12:05:52 +00:00
|
|
|
# Do basic copy tests
|
|
|
|
copy_tests ()
|
|
|
|
{
|
|
|
|
rm -f ${COPY}
|
2017-04-30 23:34:55 +00:00
|
|
|
${SSH} -nq -F $OBJ/ssh_config somehost \
|
|
|
|
cat ${DATA} > ${COPY}
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
fail "ssh cat $DATA failed"
|
|
|
|
fi
|
|
|
|
cmp ${DATA} ${COPY} || fail "corrupted copy"
|
|
|
|
rm -f ${COPY}
|
2004-12-06 12:05:52 +00:00
|
|
|
}
|
|
|
|
|
2004-06-25 03:45:18 +00:00
|
|
|
verbose "test config passing"
|
|
|
|
|
2004-12-06 12:05:52 +00:00
|
|
|
cp $OBJ/sshd_config $OBJ/sshd_config.orig
|
2004-06-25 03:45:18 +00:00
|
|
|
start_sshd
|
|
|
|
echo "InvalidXXX=no" >> $OBJ/sshd_config
|
|
|
|
|
2004-12-06 12:05:52 +00:00
|
|
|
copy_tests
|
2004-06-25 03:45:18 +00:00
|
|
|
|
2016-12-16 01:06:27 +00:00
|
|
|
stop_sshd
|
2004-06-25 03:45:18 +00:00
|
|
|
|
|
|
|
cp $OBJ/sshd_config.orig $OBJ/sshd_config
|
|
|
|
|
2012-07-02 15:06:49 +00:00
|
|
|
# cygwin can't fork a deleted binary
|
|
|
|
if [ "$os" != "cygwin" ]; then
|
|
|
|
|
2004-06-25 03:45:18 +00:00
|
|
|
verbose "test reexec fallback"
|
|
|
|
|
2004-12-06 12:05:52 +00:00
|
|
|
start_sshd_copy
|
2023-01-19 07:53:45 +00:00
|
|
|
$SUDO rm -f $SSHD_COPY
|
2004-12-06 12:05:52 +00:00
|
|
|
|
|
|
|
copy_tests
|
2004-06-25 03:45:18 +00:00
|
|
|
|
2016-12-16 01:06:27 +00:00
|
|
|
stop_sshd
|
2012-07-02 15:06:49 +00:00
|
|
|
fi
|