]> andersk Git - openssh.git/blob - regress/dynamic-forward.sh
- (dtucker) [agent-ptrace.sh dynamic-forward.sh (all regress/)]
[openssh.git] / regress / dynamic-forward.sh
1 #       $OpenBSD: dynamic-forward.sh,v 1.2 2003/07/03 08:21:46 markus Exp $
2 #       Placed in the Public Domain.
3
4 tid="dynamic forwarding"
5
6 PORT=4242
7 FWDPORT=4243
8
9 if [ -x "`which nc 2>&1`" ] && nc -h 2>&1 | grep "x proxy address" >/dev/null; then
10         proxycmd="nc -x 127.0.0.1:$FWDPORT -X"
11 elif [ -x "`which connect 2>&1`" ]; then
12         proxycmd="connect -S 127.0.0.1:$FWDPORT -"
13 else
14         echo "skipped (no suitable ProxyCommand found)"
15         exit 0
16 fi
17 trace "will use ProxyCommand $proxycmd"
18
19 start_sshd
20
21 for p in 1 2; do
22         trace "start dynamic forwarding, fork to background"
23         ${SSH} -$p -F $OBJ/ssh_config -f -D $FWDPORT -q somehost \
24                 exec sh -c \'"echo \$\$ > $OBJ/remote_pid; exec sleep 444"\'
25
26         for s in 4 5; do
27             for h in 127.0.0.1 localhost; do
28                 trace "testing ssh protocol $p socks version $s host $h"
29                 ${SSH} -F $OBJ/ssh_config \
30                         -o "ProxyCommand ${proxycmd}${s} $h $PORT" \
31                         somehost cat /bin/ls > $OBJ/ls.copy
32                 test -f $OBJ/ls.copy     || fail "failed copy /bin/ls"
33                 cmp /bin/ls $OBJ/ls.copy || fail "corrupted copy of /bin/ls"
34             done
35         done
36
37         if [ -f $OBJ/remote_pid ]; then
38                 remote=`cat $OBJ/remote_pid`
39                 trace "terminate remote shell, pid $remote"
40                 if [ $remote -gt 1 ]; then
41                         kill -HUP $remote
42                 fi
43         else
44                 fail "no pid file: $OBJ/remote_pid"
45         fi
46 done
This page took 0.455109 seconds and 5 git commands to generate.