From b29c4a59ea06290992b94689e478ebb1b7c342e8 Mon Sep 17 00:00:00 2001 From: dtucker Date: Thu, 10 Jun 2021 03:45:31 +0000 Subject: [PATCH] Add regress test for SIGHUP restart while handling active and unauthenticated clients. Should catch anything similar to the pselect bug just fixed in sshd.c. --- regress/usr.bin/ssh/reconfigure.sh | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/regress/usr.bin/ssh/reconfigure.sh b/regress/usr.bin/ssh/reconfigure.sh index b954d93b3d5..fb367cc6805 100644 --- a/regress/usr.bin/ssh/reconfigure.sh +++ b/regress/usr.bin/ssh/reconfigure.sh @@ -1,4 +1,4 @@ -# $OpenBSD: reconfigure.sh,v 1.6 2017/04/30 23:34:55 djm Exp $ +# $OpenBSD: reconfigure.sh,v 1.7 2021/06/10 03:45:31 dtucker Exp $ # Placed in the Public Domain. tid="simple connect after reconfigure" @@ -12,8 +12,9 @@ if [ $? -ne 0 ]; then fail "ssh connect with failed before reconfigure" fi -$SUDO kill -HUP `cat $PIDFILE` -sleep 1 +PID=`cat $PIDFILE` +rm -f $PIDFILE +$SUDO kill -HUP $PID trace "wait for sshd to restart" i=0; @@ -29,3 +30,25 @@ ${SSH} -F $OBJ/ssh_config somehost true if [ $? -ne 0 ]; then fail "ssh connect with failed after reconfigure" fi + +trace "reconfigure with active clients" +${SSH} -F $OBJ/ssh_config somehost sleep 10 # authenticated client +${NC} -d 127.0.0.1 $PORT >/dev/null & # unauthenticated client +PID=`cat $PIDFILE` +rm -f $PIDFILE +$SUDO kill -HUP $PID + +trace "wait for sshd to restart" +i=0; +while [ ! -f $PIDFILE -a $i -lt 10 ]; do + i=`expr $i + 1` + sleep $i +done + +test -f $PIDFILE || fatal "sshd did not restart" + +trace "connect after restart with active clients" +${SSH} -F $OBJ/ssh_config somehost true +if [ $? -ne 0 ]; then + fail "ssh connect with failed after reconfigure" +fi -- 2.20.1