xref: /freebsd/crypto/openssh/regress/reexec.sh (revision f677a9e2672665f4eb3dd4111c07ee8f1f954262)
1#	$OpenBSD: reexec.sh,v 1.7 2013/05/17 10:23:52 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	cp $SSHD_ORIG $SSHD_COPY
13	SSHD=$SSHD_COPY
14	start_sshd
15	SSHD=$SSHD_ORIG
16}
17
18# Do basic copy tests
19copy_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
34verbose "test config passing"
35
36cp $OBJ/sshd_config $OBJ/sshd_config.orig
37start_sshd
38echo "InvalidXXX=no" >> $OBJ/sshd_config
39
40copy_tests
41
42$SUDO kill `$SUDO cat $PIDFILE`
43rm -f $PIDFILE
44
45cp $OBJ/sshd_config.orig $OBJ/sshd_config
46
47# cygwin can't fork a deleted binary
48if [ "$os" != "cygwin" ]; then
49
50verbose "test reexec fallback"
51
52start_sshd_copy
53rm -f $SSHD_COPY
54
55copy_tests
56
57$SUDO kill `$SUDO cat $PIDFILE`
58rm -f $PIDFILE
59
60verbose "test reexec fallback without privsep"
61
62cp $OBJ/sshd_config.orig $OBJ/sshd_config
63echo "UsePrivilegeSeparation=no" >> $OBJ/sshd_config
64
65start_sshd_copy
66rm -f $SSHD_COPY
67
68copy_tests
69
70$SUDO kill `$SUDO cat $PIDFILE`
71rm -f $PIDFILE
72
73fi
74