summaryrefslogtreecommitdiff
path: root/regress/multiplex.sh
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2014-07-21 09:52:54 +1000
committerDamien Miller <djm@mindrot.org>2014-07-21 09:52:54 +1000
commit0e4e95566cd95c887f69272499b8f3880b3ec0f5 (patch)
tree3e47b730b4581b5c7075b1d6df62dbf1780d23a1 /regress/multiplex.sh
parent93a87ab27ecdc709169fb24411133998f81e2761 (diff)
- millert@cvs.openbsd.org 2014/07/15 15:54:15
[forwarding.sh multiplex.sh] Add support for Unix domain socket forwarding. A remote TCP port may be forwarded to a local Unix domain socket and vice versa or both ends may be a Unix domain socket. This is a reimplementation of the streamlocal patches by William Ahern from: http://www.25thandclement.com/~william/projects/streamlocal.html OK djm@ markus@
Diffstat (limited to 'regress/multiplex.sh')
-rw-r--r--regress/multiplex.sh47
1 files changed, 44 insertions, 3 deletions
diff --git a/regress/multiplex.sh b/regress/multiplex.sh
index 0a9ed2fbf..9f5fc38ea 100644
--- a/regress/multiplex.sh
+++ b/regress/multiplex.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: multiplex.sh,v 1.23 2014/07/07 08:15:26 djm Exp $ 1# $OpenBSD: multiplex.sh,v 1.24 2014/07/15 15:54:15 millert Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4CTL=/tmp/openssh.regress.ctl-sock.$$ 4CTL=/tmp/openssh.regress.ctl-sock.$$
@@ -72,6 +72,25 @@ test -f ${COPY} || fail "scp: failed copy ${DATA}"
72cmp ${DATA} ${COPY} || fail "scp: corrupted copy of ${DATA}" 72cmp ${DATA} ${COPY} || fail "scp: corrupted copy of ${DATA}"
73 73
74rm -f ${COPY} 74rm -f ${COPY}
75verbose "test $tid: forward"
76trace "forward over TCP/IP and check result"
77nc -N -l 127.0.0.1 $((${PORT} + 1)) < ${DATA} &
78netcat_pid=$!
79${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L127.0.0.1:$((${PORT} + 2)):127.0.0.1:$((${PORT} + 1)) otherhost >>$TEST_SSH_LOGFILE 2>&1
80nc 127.0.0.1 $((${PORT} + 2)) > ${COPY}
81cmp ${DATA} ${COPY} || fail "ssh: corrupted copy of ${DATA}"
82kill $netcat_pid 2>/dev/null
83rm -f ${COPY} $OBJ/unix-[123].fwd
84
85trace "forward over UNIX and check result"
86nc -N -Ul $OBJ/unix-1.fwd < ${DATA} &
87netcat_pid=$!
88${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L$OBJ/unix-2.fwd:$OBJ/unix-1.fwd otherhost >>$TEST_SSH_LOGFILE 2>&1
89${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -R$OBJ/unix-3.fwd:$OBJ/unix-2.fwd otherhost >>$TEST_SSH_LOGFILE 2>&1
90nc -U $OBJ/unix-3.fwd > ${COPY}
91cmp ${DATA} ${COPY} || fail "ssh: corrupted copy of ${DATA}"
92kill $netcat_pid 2>/dev/null
93rm -f ${COPY} $OBJ/unix-[123].fwd
75 94
76for s in 0 1 4 5 44; do 95for s in 0 1 4 5 44; do
77 trace "exit status $s over multiplexed connection" 96 trace "exit status $s over multiplexed connection"
@@ -96,7 +115,7 @@ verbose "test $tid: cmd check"
96${SSH} -F $OBJ/ssh_config -S $CTL -Ocheck otherhost >>$TEST_REGRESS_LOGFILE 2>&1 \ 115${SSH} -F $OBJ/ssh_config -S $CTL -Ocheck otherhost >>$TEST_REGRESS_LOGFILE 2>&1 \
97 || fail "check command failed" 116 || fail "check command failed"
98 117
99verbose "test $tid: cmd forward local" 118verbose "test $tid: cmd forward local (TCP)"
100${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L $P:localhost:$PORT otherhost \ 119${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L $P:localhost:$PORT otherhost \
101 || fail "request local forward failed" 120 || fail "request local forward failed"
102${SSH} -F $OBJ/ssh_config -p$P otherhost true \ 121${SSH} -F $OBJ/ssh_config -p$P otherhost true \
@@ -106,7 +125,7 @@ ${SSH} -F $OBJ/ssh_config -S $CTL -Ocancel -L $P:localhost:$PORT otherhost \
106${SSH} -F $OBJ/ssh_config -p$P otherhost true \ 125${SSH} -F $OBJ/ssh_config -p$P otherhost true \
107 && fail "local forward port still listening" 126 && fail "local forward port still listening"
108 127
109verbose "test $tid: cmd forward remote" 128verbose "test $tid: cmd forward remote (TCP)"
110${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -R $P:localhost:$PORT otherhost \ 129${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -R $P:localhost:$PORT otherhost \
111 || fail "request remote forward failed" 130 || fail "request remote forward failed"
112${SSH} -F $OBJ/ssh_config -p$P otherhost true \ 131${SSH} -F $OBJ/ssh_config -p$P otherhost true \
@@ -116,6 +135,28 @@ ${SSH} -F $OBJ/ssh_config -S $CTL -Ocancel -R $P:localhost:$PORT otherhost \
116${SSH} -F $OBJ/ssh_config -p$P otherhost true \ 135${SSH} -F $OBJ/ssh_config -p$P otherhost true \
117 && fail "remote forward port still listening" 136 && fail "remote forward port still listening"
118 137
138verbose "test $tid: cmd forward local (UNIX)"
139${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L $OBJ/unix-1.fwd:localhost:$PORT otherhost \
140 || fail "request local forward failed"
141echo "" | nc -U $OBJ/unix-1.fwd | grep "Protocol mismatch" >/dev/null 2>&1 \
142 || fail "connect to local forward path failed"
143${SSH} -F $OBJ/ssh_config -S $CTL -Ocancel -L $OBJ/unix-1.fwd:localhost:$PORT otherhost \
144 || fail "cancel local forward failed"
145N=$(echo "" | nc -U $OBJ/unix-1.fwd 2>&1 | wc -l)
146test ${N} -eq 0 || fail "local forward path still listening"
147rm -f $OBJ/unix-1.fwd
148
149verbose "test $tid: cmd forward remote (UNIX)"
150${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -R $OBJ/unix-1.fwd:localhost:$PORT otherhost \
151 || fail "request remote forward failed"
152echo "" | nc -U $OBJ/unix-1.fwd | grep "Protocol mismatch" >/dev/null 2>&1 \
153 || fail "connect to remote forwarded path failed"
154${SSH} -F $OBJ/ssh_config -S $CTL -Ocancel -R $OBJ/unix-1.fwd:localhost:$PORT otherhost \
155 || fail "cancel remote forward failed"
156N=$(echo "" | nc -U $OBJ/unix-1.fwd 2>&1 | wc -l)
157test ${N} -eq 0 || fail "remote forward path still listening"
158rm -f $OBJ/unix-1.fwd
159
119verbose "test $tid: cmd exit" 160verbose "test $tid: cmd exit"
120${SSH} -F $OBJ/ssh_config -S $CTL -Oexit otherhost >>$TEST_REGRESS_LOGFILE 2>&1 \ 161${SSH} -F $OBJ/ssh_config -S $CTL -Oexit otherhost >>$TEST_REGRESS_LOGFILE 2>&1 \
121 || fail "send exit command failed" 162 || fail "send exit command failed"