1 # $OpenBSD: forwarding.sh,v 1.6 2006/07/11 18:51:21 markus Exp $
2 # Placed in the Public Domain.
4 tid
="local and remote forwarding"
17 # fwd chain: $a -> $b -> $c
18 fwd
="$fwd -L$a:127.0.0.1:$b -R$b:127.0.0.1:$c"
24 trace
"start forwarding, fork to background"
25 ${SSH} -$p -F $OBJ/ssh_config
-f $fwd somehost
sleep 10
27 trace
"transfer over forwarded channels and check result"
28 ${SSH} -$q -F $OBJ/ssh_config
-p$last -o 'ConnectionAttempts=4' \
29 somehost
cat $DATA > $OBJ/ls.copy
30 test -f $OBJ/ls.copy || fail
"failed copy $DATA"
31 cmp $DATA $OBJ/ls.copy || fail
"corrupted copy of $DATA"
38 trace
"exit on -$d forward failure, proto $p"
40 # this one should succeed
41 ${SSH} -$p -F $OBJ/ssh_config \
42 -$d ${base}01:127.0.0.1:$PORT \
43 -$d ${base}02:127.0.0.1:$PORT \
44 -$d ${base}03:127.0.0.1:$PORT \
45 -$d ${base}04:127.0.0.1:$PORT \
46 -oExitOnForwardFailure=yes somehost true
48 fail
"connection failed, should not"
50 # this one should fail
51 ${SSH} -q -$p -F $OBJ/ssh_config \
52 -$d ${base}01:127.0.0.1:$PORT \
53 -$d ${base}02:127.0.0.1:$PORT \
54 -$d ${base}03:127.0.0.1:$PORT \
55 -$d ${base}01:127.0.0.1:$PORT \
56 -$d ${base}04:127.0.0.1:$PORT \
57 -oExitOnForwardFailure=yes somehost true
59 if [ $r != 255 ]; then
60 fail
"connection not termintated, but should ($r)"
67 trace
"simple clear forwarding proto $p"
68 ${SSH} -$p -F $OBJ/ssh_config
-oClearAllForwardings=yes somehost true
70 trace
"clear local forward proto $p"
71 ${SSH} -$p -f -F $OBJ/ssh_config
-L ${base}01:127.0.0.1:$PORT \
72 -oClearAllForwardings=yes somehost
sleep 10
74 fail
"connection failed with cleared local forwarding"
76 # this one should fail
77 ${SSH} -$p -F $OBJ/ssh_config
-p ${base}01 true \
78 2>${TEST_SSH_LOGFILE} && \
79 fail
"local forwarding not cleared"
83 trace
"clear remote forward proto $p"
84 ${SSH} -$p -f -F $OBJ/ssh_config
-R ${base}01:127.0.0.1:$PORT \
85 -oClearAllForwardings=yes somehost
sleep 10
87 fail
"connection failed with cleared remote forwarding"
89 # this one should fail
90 ${SSH} -$p -F $OBJ/ssh_config
-p ${base}01 true \
91 2>${TEST_SSH_LOGFILE} && \
92 fail
"remote forwarding not cleared"