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