summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/dynamic-forward.sh73
1 files changed, 38 insertions, 35 deletions
diff --git a/regress/dynamic-forward.sh b/regress/dynamic-forward.sh
index 2c176b69f..84f8ee192 100644
--- a/regress/dynamic-forward.sh
+++ b/regress/dynamic-forward.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: dynamic-forward.sh,v 1.12 2017/04/30 23:34:55 djm Exp $ 1# $OpenBSD: dynamic-forward.sh,v 1.13 2017/09/21 19:18:12 markus Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="dynamic forwarding" 4tid="dynamic forwarding"
@@ -17,42 +17,45 @@ trace "will use ProxyCommand $proxycmd"
17 17
18start_sshd 18start_sshd
19 19
20n=0 20for d in D R; do
21error="1" 21 n=0
22trace "start dynamic forwarding, fork to background" 22 error="1"
23while [ "$error" -ne 0 -a "$n" -lt 3 ]; do 23 trace "start dynamic forwarding, fork to background"
24 n=`expr $n + 1` 24
25 ${SSH} -F $OBJ/ssh_config -f -D $FWDPORT -q \ 25 while [ "$error" -ne 0 -a "$n" -lt 3 ]; do
26 -oExitOnForwardFailure=yes somehost exec sh -c \ 26 n=`expr $n + 1`
27 \'"echo \$\$ > $OBJ/remote_pid; exec sleep 444"\' 27 ${SSH} -F $OBJ/ssh_config -f -$d $FWDPORT -q \
28 error=$? 28 -oExitOnForwardFailure=yes somehost exec sh -c \
29 \'"echo \$\$ > $OBJ/remote_pid; exec sleep 444"\'
30 error=$?
31 if [ "$error" -ne 0 ]; then
32 trace "forward failed attempt $n err $error"
33 sleep $n
34 fi
35 done
29 if [ "$error" -ne 0 ]; then 36 if [ "$error" -ne 0 ]; then
30 trace "forward failed attempt $n err $error" 37 fatal "failed to start dynamic forwarding"
31 sleep $n
32 fi 38 fi
33done
34if [ "$error" -ne 0 ]; then
35 fatal "failed to start dynamic forwarding"
36fi
37
38for s in 4 5; do
39 for h in 127.0.0.1 localhost; do
40 trace "testing ssh socks version $s host $h"
41 ${SSH} -F $OBJ/ssh_config \
42 -o "ProxyCommand ${proxycmd}${s} $h $PORT" \
43 somehost cat ${DATA} > ${COPY}
44 test -f ${COPY} || fail "failed copy ${DATA}"
45 cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}"
46 done
47done
48 39
49if [ -f $OBJ/remote_pid ]; then 40 for s in 4 5; do
50 remote=`cat $OBJ/remote_pid` 41 for h in 127.0.0.1 localhost; do
51 trace "terminate remote shell, pid $remote" 42 trace "testing ssh socks version $s host $h (-$d)"
52 if [ $remote -gt 1 ]; then 43 ${SSH} -F $OBJ/ssh_config \
53 kill -HUP $remote 44 -o "ProxyCommand ${proxycmd}${s} $h $PORT" \
45 somehost cat ${DATA} > ${COPY}
46 test -f ${COPY} || fail "failed copy ${DATA}"
47 cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}"
48 done
49 done
50
51 if [ -f $OBJ/remote_pid ]; then
52 remote=`cat $OBJ/remote_pid`
53 trace "terminate remote shell, pid $remote"
54 if [ $remote -gt 1 ]; then
55 kill -HUP $remote
56 fi
57 else
58 fail "no pid file: $OBJ/remote_pid"
54 fi 59 fi
55else
56 fail "no pid file: $OBJ/remote_pid"
57fi
58 60
61done