upstream: Simplify forward-control test.
Since we no longer need to support SSH1 we don't need to run shell commands on the other end of the connection and can use ssh -N instead. This also makes the test less racy. OpenBSD-Regress-ID: 32e94ce272820cc398f30b848b2b0f080d10302c
This commit is contained in:
parent
687bbf2357
commit
5f76286a12
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: forward-control.sh,v 1.8 2021/05/07 09:23:40 dtucker Exp $
|
# $OpenBSD: forward-control.sh,v 1.9 2022/04/20 05:24:13 dtucker Exp $
|
||||||
# Placed in the Public Domain.
|
# Placed in the Public Domain.
|
||||||
|
|
||||||
tid="sshd control of local and remote forwarding"
|
tid="sshd control of local and remote forwarding"
|
||||||
|
@ -6,19 +6,7 @@ tid="sshd control of local and remote forwarding"
|
||||||
LFWD_PORT=3320
|
LFWD_PORT=3320
|
||||||
RFWD_PORT=3321
|
RFWD_PORT=3321
|
||||||
CTL=$OBJ/ctl-sock
|
CTL=$OBJ/ctl-sock
|
||||||
READY=$OBJ/ready
|
WAIT_SECONDS=20
|
||||||
|
|
||||||
wait_for_file_to_appear() {
|
|
||||||
_path=$1
|
|
||||||
_n=0
|
|
||||||
while test ! -f $_path ; do
|
|
||||||
test $_n -eq 1 && trace "waiting for $_path to appear"
|
|
||||||
_n=`expr $_n + 1`
|
|
||||||
test $_n -ge 20 && return 1
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
wait_for_process_to_exit() {
|
wait_for_process_to_exit() {
|
||||||
_pid=$1
|
_pid=$1
|
||||||
|
@ -26,7 +14,7 @@ wait_for_process_to_exit() {
|
||||||
while kill -0 $_pid 2>/dev/null ; do
|
while kill -0 $_pid 2>/dev/null ; do
|
||||||
test $_n -eq 1 && trace "waiting for $_pid to exit"
|
test $_n -eq 1 && trace "waiting for $_pid to exit"
|
||||||
_n=`expr $_n + 1`
|
_n=`expr $_n + 1`
|
||||||
test $_n -ge 20 && return 1
|
test $_n -ge $WAIT_SECONDS && return 1
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
return 0
|
return 0
|
||||||
|
@ -36,19 +24,18 @@ wait_for_process_to_exit() {
|
||||||
check_lfwd() {
|
check_lfwd() {
|
||||||
_expected=$1
|
_expected=$1
|
||||||
_message=$2
|
_message=$2
|
||||||
rm -f $READY
|
|
||||||
${SSH} -F $OBJ/ssh_proxy \
|
${SSH} -F $OBJ/ssh_proxy \
|
||||||
-L$LFWD_PORT:127.0.0.1:$PORT \
|
-L$LFWD_PORT:127.0.0.1:$PORT \
|
||||||
-o ExitOnForwardFailure=yes \
|
-o ExitOnForwardFailure=yes \
|
||||||
-n host exec sh -c \'"sleep 60 & echo \$! > $READY ; wait "\' \
|
-n -N host >/dev/null 2>&1 &
|
||||||
>/dev/null 2>&1 &
|
|
||||||
_sshpid=$!
|
_sshpid=$!
|
||||||
wait_for_file_to_appear $READY || \
|
if test $? -ne 0; then
|
||||||
fatal "check_lfwd ssh fail: $_message"
|
fatal "check_lfwd ssh fail: $_message"
|
||||||
|
fi
|
||||||
${SSH} -F $OBJ/ssh_config -p $LFWD_PORT \
|
${SSH} -F $OBJ/ssh_config -p $LFWD_PORT \
|
||||||
-oConnectionAttempts=10 host true >/dev/null 2>&1
|
-oConnectionAttempts=10 host true >/dev/null 2>&1
|
||||||
_result=$?
|
_result=$?
|
||||||
kill $_sshpid `cat $READY` 2>/dev/null
|
kill $_sshpid 2>/dev/null
|
||||||
wait_for_process_to_exit $_sshpid
|
wait_for_process_to_exit $_sshpid
|
||||||
if test "x$_expected" = "xY" -a $_result -ne 0 ; then
|
if test "x$_expected" = "xY" -a $_result -ne 0 ; then
|
||||||
fail "check_lfwd failed (expecting success): $_message"
|
fail "check_lfwd failed (expecting success): $_message"
|
||||||
|
@ -65,20 +52,17 @@ check_lfwd() {
|
||||||
check_rfwd() {
|
check_rfwd() {
|
||||||
_expected=$1
|
_expected=$1
|
||||||
_message=$2
|
_message=$2
|
||||||
rm -f $READY
|
|
||||||
${SSH} -F $OBJ/ssh_proxy \
|
${SSH} -F $OBJ/ssh_proxy \
|
||||||
-R127.0.0.1:$RFWD_PORT:127.0.0.1:$PORT \
|
-R127.0.0.1:$RFWD_PORT:127.0.0.1:$PORT \
|
||||||
-o ExitOnForwardFailure=yes \
|
-o ExitOnForwardFailure=yes \
|
||||||
-n host exec sh -c \'"sleep 60 & echo \$! > $READY ; wait "\' \
|
-n -N host >/dev/null 2>&1 &
|
||||||
>/dev/null 2>&1 &
|
|
||||||
_sshpid=$!
|
_sshpid=$!
|
||||||
wait_for_file_to_appear $READY
|
|
||||||
_result=$?
|
_result=$?
|
||||||
if test $_result -eq 0 ; then
|
if test $_result -eq 0 ; then
|
||||||
${SSH} -F $OBJ/ssh_config -p $RFWD_PORT \
|
${SSH} -F $OBJ/ssh_config -p $RFWD_PORT \
|
||||||
-oConnectionAttempts=10 host true >/dev/null 2>&1
|
-oConnectionAttempts=10 host true >/dev/null 2>&1
|
||||||
_result=$?
|
_result=$?
|
||||||
kill $_sshpid `cat $READY` 2>/dev/null
|
kill $_sshpid 2>/dev/null
|
||||||
wait_for_process_to_exit $_sshpid
|
wait_for_process_to_exit $_sshpid
|
||||||
fi
|
fi
|
||||||
if test "x$_expected" = "xY" -a $_result -ne 0 ; then
|
if test "x$_expected" = "xY" -a $_result -ne 0 ; then
|
||||||
|
|
Loading…
Reference in New Issue