upstream: Use ssh -f and ControlPersist ..

to start up test forwards and ssh -O stop to shut them down intead of
sleep loops.  This speeds up the test by an order of magnitude.

OpenBSD-Regress-ID: eb3db5f805100919b092a3b2579c611fba3e83e7
This commit is contained in:
dtucker@openbsd.org 2022-04-20 13:25:55 +00:00 committed by Darren Tucker
parent 5f76286a12
commit d19b21afab
1 changed files with 11 additions and 13 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: forward-control.sh,v 1.9 2022/04/20 05:24:13 dtucker Exp $
# $OpenBSD: forward-control.sh,v 1.10 2022/04/20 13:25:55 dtucker Exp $
# Placed in the Public Domain.
tid="sshd control of local and remote forwarding"
@ -27,16 +27,14 @@ check_lfwd() {
${SSH} -F $OBJ/ssh_proxy \
-L$LFWD_PORT:127.0.0.1:$PORT \
-o ExitOnForwardFailure=yes \
-n -N host >/dev/null 2>&1 &
_sshpid=$!
if test $? -ne 0; then
-MS $CTL -o ControlPersist=yes \
-f host true
${SSH} -F $OBJ/ssh_proxy -S $CTL -O check host >/dev/null 2>&1 || \
fatal "check_lfwd ssh fail: $_message"
fi
${SSH} -F $OBJ/ssh_config -p $LFWD_PORT \
-oConnectionAttempts=10 host true >/dev/null 2>&1
_result=$?
kill $_sshpid 2>/dev/null
wait_for_process_to_exit $_sshpid
${SSH} -F $OBJ/ssh_proxy -S $CTL -O exit host >/dev/null 2>&1
if test "x$_expected" = "xY" -a $_result -ne 0 ; then
fail "check_lfwd failed (expecting success): $_message"
elif test "x$_expected" = "xN" -a $_result -eq 0 ; then
@ -55,15 +53,15 @@ check_rfwd() {
${SSH} -F $OBJ/ssh_proxy \
-R127.0.0.1:$RFWD_PORT:127.0.0.1:$PORT \
-o ExitOnForwardFailure=yes \
-n -N host >/dev/null 2>&1 &
_sshpid=$!
-MS $CTL -o ControlPersist=yes \
-f host true
${SSH} -F $OBJ/ssh_proxy -S $CTL -O check host >/dev/null 2>&1
_result=$?
if test $_result -eq 0 ; then
if ${SSH} -F $OBJ/ssh_proxy -S $CTL -O check host >/dev/null 2>&1; then
${SSH} -F $OBJ/ssh_config -p $RFWD_PORT \
-oConnectionAttempts=10 host true >/dev/null 2>&1
_result=$?
kill $_sshpid 2>/dev/null
wait_for_process_to_exit $_sshpid
${SSH} -F $OBJ/ssh_proxy -S $CTL -O exit host >/dev/null 2>&1
fi
if test "x$_expected" = "xY" -a $_result -ne 0 ; then
fail "check_rfwd failed (expecting success): $_message"