xref: /freebsd/crypto/openssh/regress/reconfigure.sh (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
1#	$OpenBSD: reconfigure.sh,v 1.9 2021/06/10 09:46:28 dtucker Exp $
2#	Placed in the Public Domain.
3
4tid="simple connect after reconfigure"
5
6# we need the full path to sshd for -HUP
7if test "x$USE_VALGRIND" = "x" ; then
8	case $SSHD in
9	/*)
10		# full path is OK
11		;;
12	*)
13		# otherwise make fully qualified
14		SSHD=$OBJ/$SSHD
15	esac
16fi
17
18start_sshd
19
20trace "connect before restart"
21${SSH} -F $OBJ/ssh_config somehost true
22if [ $? -ne 0 ]; then
23	fail "ssh connect with failed before reconfigure"
24fi
25
26PID=`$SUDO cat $PIDFILE`
27rm -f $PIDFILE
28$SUDO kill -HUP $PID
29
30trace "wait for sshd to restart"
31i=0;
32while [ ! -f $PIDFILE -a $i -lt 10 ]; do
33	i=`expr $i + 1`
34	sleep $i
35done
36
37test -f $PIDFILE || fatal "sshd did not restart"
38
39trace "connect after restart"
40${SSH} -F $OBJ/ssh_config somehost true
41if [ $? -ne 0 ]; then
42	fail "ssh connect with failed after reconfigure"
43fi
44
45trace "reconfigure with active clients"
46${SSH} -F $OBJ/ssh_config somehost sleep 10  # authenticated client
47${NC} -d 127.0.0.1 $PORT >/dev/null &  # unauthenticated client
48PID=`$SUDO cat $PIDFILE`
49rm -f $PIDFILE
50$SUDO kill -HUP $PID
51
52trace "wait for sshd to restart"
53i=0;
54while [ ! -f $PIDFILE -a $i -lt 10 ]; do
55	i=`expr $i + 1`
56	sleep $i
57done
58
59test -f $PIDFILE || fatal "sshd did not restart"
60
61trace "connect after restart with active clients"
62${SSH} -F $OBJ/ssh_config somehost true
63if [ $? -ne 0 ]; then
64	fail "ssh connect with failed after reconfigure"
65fi
66