diff options
Diffstat (limited to 'regress/dynamic-forward.sh')
-rw-r--r-- | regress/dynamic-forward.sh | 73 |
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 | ||
4 | tid="dynamic forwarding" | 4 | tid="dynamic forwarding" |
@@ -17,42 +17,45 @@ trace "will use ProxyCommand $proxycmd" | |||
17 | 17 | ||
18 | start_sshd | 18 | start_sshd |
19 | 19 | ||
20 | n=0 | 20 | for d in D R; do |
21 | error="1" | 21 | n=0 |
22 | trace "start dynamic forwarding, fork to background" | 22 | error="1" |
23 | while [ "$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 |
33 | done | ||
34 | if [ "$error" -ne 0 ]; then | ||
35 | fatal "failed to start dynamic forwarding" | ||
36 | fi | ||
37 | |||
38 | for 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 | ||
47 | done | ||
48 | 39 | ||
49 | if [ -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 |
55 | else | ||
56 | fail "no pid file: $OBJ/remote_pid" | ||
57 | fi | ||
58 | 60 | ||
61 | done | ||