summaryrefslogtreecommitdiff
path: root/regress/forwarding.sh
diff options
context:
space:
mode:
Diffstat (limited to 'regress/forwarding.sh')
-rw-r--r--regress/forwarding.sh44
1 files changed, 25 insertions, 19 deletions
diff --git a/regress/forwarding.sh b/regress/forwarding.sh
index 2539db9b7..45c596d7d 100644
--- a/regress/forwarding.sh
+++ b/regress/forwarding.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: forwarding.sh,v 1.16 2016/04/14 23:57:17 djm Exp $ 1# $OpenBSD: forwarding.sh,v 1.19 2017/01/30 05:22:14 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="local and remote forwarding" 4tid="local and remote forwarding"
@@ -10,8 +10,7 @@ start_sshd
10base=33 10base=33
11last=$PORT 11last=$PORT
12fwd="" 12fwd=""
13CTL=$OBJ/ctl-sock 13CTL=/tmp/openssh.regress.ctl-sock.$$
14rm -f $CTL
15 14
16for j in 0 1 2; do 15for j in 0 1 2; do
17 for i in 0 1 2; do 16 for i in 0 1 2; do
@@ -29,7 +28,8 @@ for p in ${SSH_PROTOCOLS}; do
29 q=$p 28 q=$p
30 fi 29 fi
31 trace "start forwarding, fork to background" 30 trace "start forwarding, fork to background"
32 ${SSH} -$p -F $OBJ/ssh_config -f $fwd somehost sleep 10 31 rm -f $CTL
32 ${SSH} -S $CTL -M -$p -F $OBJ/ssh_config -f $fwd somehost sleep 10
33 33
34 trace "transfer over forwarded channels and check result" 34 trace "transfer over forwarded channels and check result"
35 ${SSH} -$q -F $OBJ/ssh_config -p$last -o 'ConnectionAttempts=4' \ 35 ${SSH} -$q -F $OBJ/ssh_config -p$last -o 'ConnectionAttempts=4' \
@@ -37,7 +37,7 @@ for p in ${SSH_PROTOCOLS}; do
37 test -s ${COPY} || fail "failed copy of ${DATA}" 37 test -s ${COPY} || fail "failed copy of ${DATA}"
38 cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}" 38 cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}"
39 39
40 sleep 10 40 ${SSH} -F $OBJ/ssh_config -S $CTL -O exit somehost
41done 41done
42 42
43for p in ${SSH_PROTOCOLS}; do 43for p in ${SSH_PROTOCOLS}; do
@@ -52,7 +52,7 @@ for d in L R; do
52 -$d ${base}04:127.0.0.1:$PORT \ 52 -$d ${base}04:127.0.0.1:$PORT \
53 -oExitOnForwardFailure=yes somehost true 53 -oExitOnForwardFailure=yes somehost true
54 if [ $? != 0 ]; then 54 if [ $? != 0 ]; then
55 fail "connection failed, should not" 55 fatal "connection failed, should not"
56 else 56 else
57 # this one should fail 57 # this one should fail
58 ${SSH} -q -$p -F $OBJ/ssh_config \ 58 ${SSH} -q -$p -F $OBJ/ssh_config \
@@ -75,30 +75,32 @@ for p in ${SSH_PROTOCOLS}; do
75 ${SSH} -$p -F $OBJ/ssh_config -oClearAllForwardings=yes somehost true 75 ${SSH} -$p -F $OBJ/ssh_config -oClearAllForwardings=yes somehost true
76 76
77 trace "clear local forward proto $p" 77 trace "clear local forward proto $p"
78 ${SSH} -$p -f -F $OBJ/ssh_config -L ${base}01:127.0.0.1:$PORT \ 78 rm -f $CTL
79 ${SSH} -S $CTL -M -$p -f -F $OBJ/ssh_config -L ${base}01:127.0.0.1:$PORT \
79 -oClearAllForwardings=yes somehost sleep 10 80 -oClearAllForwardings=yes somehost sleep 10
80 if [ $? != 0 ]; then 81 if [ $? != 0 ]; then
81 fail "connection failed with cleared local forwarding" 82 fail "connection failed with cleared local forwarding"
82 else 83 else
83 # this one should fail 84 # this one should fail
84 ${SSH} -$p -F $OBJ/ssh_config -p ${base}01 true \ 85 ${SSH} -$p -F $OBJ/ssh_config -p ${base}01 somehost true \
85 >>$TEST_REGRESS_LOGFILE 2>&1 && \ 86 >>$TEST_REGRESS_LOGFILE 2>&1 && \
86 fail "local forwarding not cleared" 87 fail "local forwarding not cleared"
87 fi 88 fi
88 sleep 10 89 ${SSH} -F $OBJ/ssh_config -S $CTL -O exit somehost
89 90
90 trace "clear remote forward proto $p" 91 trace "clear remote forward proto $p"
91 ${SSH} -$p -f -F $OBJ/ssh_config -R ${base}01:127.0.0.1:$PORT \ 92 rm -f $CTL
93 ${SSH} -S $CTL -M -$p -f -F $OBJ/ssh_config -R ${base}01:127.0.0.1:$PORT \
92 -oClearAllForwardings=yes somehost sleep 10 94 -oClearAllForwardings=yes somehost sleep 10
93 if [ $? != 0 ]; then 95 if [ $? != 0 ]; then
94 fail "connection failed with cleared remote forwarding" 96 fail "connection failed with cleared remote forwarding"
95 else 97 else
96 # this one should fail 98 # this one should fail
97 ${SSH} -$p -F $OBJ/ssh_config -p ${base}01 true \ 99 ${SSH} -$p -F $OBJ/ssh_config -p ${base}01 somehost true \
98 >>$TEST_REGRESS_LOGFILE 2>&1 && \ 100 >>$TEST_REGRESS_LOGFILE 2>&1 && \
99 fail "remote forwarding not cleared" 101 fail "remote forwarding not cleared"
100 fi 102 fi
101 sleep 10 103 ${SSH} -F $OBJ/ssh_config -S $CTL -O exit somehost
102done 104done
103 105
104for p in 2; do 106for p in 2; do
@@ -115,6 +117,7 @@ echo "LocalForward ${base}01 127.0.0.1:$PORT" >> $OBJ/ssh_config
115echo "RemoteForward ${base}02 127.0.0.1:${base}01" >> $OBJ/ssh_config 117echo "RemoteForward ${base}02 127.0.0.1:${base}01" >> $OBJ/ssh_config
116for p in ${SSH_PROTOCOLS}; do 118for p in ${SSH_PROTOCOLS}; do
117 trace "config file: start forwarding, fork to background" 119 trace "config file: start forwarding, fork to background"
120 rm -f $CTL
118 ${SSH} -S $CTL -M -$p -F $OBJ/ssh_config -f somehost sleep 10 121 ${SSH} -S $CTL -M -$p -F $OBJ/ssh_config -f somehost sleep 10
119 122
120 trace "config file: transfer over forwarded channels and check result" 123 trace "config file: transfer over forwarded channels and check result"
@@ -123,21 +126,24 @@ for p in ${SSH_PROTOCOLS}; do
123 test -s ${COPY} || fail "failed copy of ${DATA}" 126 test -s ${COPY} || fail "failed copy of ${DATA}"
124 cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}" 127 cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}"
125 128
126 ${SSH} -S $CTL -O exit somehost 129 ${SSH} -F $OBJ/ssh_config -S $CTL -O exit somehost
127done 130done
128 131
129for p in 2; do 132for p in 2; do
130 trace "transfer over chained unix domain socket forwards and check result" 133 trace "transfer over chained unix domain socket forwards and check result"
131 rm -f $OBJ/unix-[123].fwd 134 rm -f $OBJ/unix-[123].fwd
132 ${SSH} -f -F $OBJ/ssh_config -R${base}01:[$OBJ/unix-1.fwd] somehost sleep 10 135 rm -f $CTL $CTL.[123]
133 ${SSH} -f -F $OBJ/ssh_config -L[$OBJ/unix-1.fwd]:[$OBJ/unix-2.fwd] somehost sleep 10 136 ${SSH} -S $CTL -M -f -F $OBJ/ssh_config -R${base}01:[$OBJ/unix-1.fwd] somehost sleep 10
134 ${SSH} -f -F $OBJ/ssh_config -R[$OBJ/unix-2.fwd]:[$OBJ/unix-3.fwd] somehost sleep 10 137 ${SSH} -S $CTL.1 -M -f -F $OBJ/ssh_config -L[$OBJ/unix-1.fwd]:[$OBJ/unix-2.fwd] somehost sleep 10
135 ${SSH} -f -F $OBJ/ssh_config -L[$OBJ/unix-3.fwd]:127.0.0.1:$PORT somehost sleep 10 138 ${SSH} -S $CTL.2 -M -f -F $OBJ/ssh_config -R[$OBJ/unix-2.fwd]:[$OBJ/unix-3.fwd] somehost sleep 10
139 ${SSH} -S $CTL.3 -M -f -F $OBJ/ssh_config -L[$OBJ/unix-3.fwd]:127.0.0.1:$PORT somehost sleep 10
136 ${SSH} -F $OBJ/ssh_config -p${base}01 -o 'ConnectionAttempts=4' \ 140 ${SSH} -F $OBJ/ssh_config -p${base}01 -o 'ConnectionAttempts=4' \
137 somehost cat ${DATA} > ${COPY} 141 somehost cat ${DATA} > ${COPY}
138 test -s ${COPY} || fail "failed copy ${DATA}" 142 test -s ${COPY} || fail "failed copy ${DATA}"
139 cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}" 143 cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}"
140 144
141 #wait 145 ${SSH} -F $OBJ/ssh_config -S $CTL -O exit somehost
142 sleep 10 146 ${SSH} -F $OBJ/ssh_config -S $CTL.1 -O exit somehost
147 ${SSH} -F $OBJ/ssh_config -S $CTL.2 -O exit somehost
148 ${SSH} -F $OBJ/ssh_config -S $CTL.3 -O exit somehost
143done 149done