diff options
Diffstat (limited to 'regress/multiplex.sh')
-rw-r--r-- | regress/multiplex.sh | 76 |
1 files changed, 68 insertions, 8 deletions
diff --git a/regress/multiplex.sh b/regress/multiplex.sh index 3e697e691..8ee140be6 100644 --- a/regress/multiplex.sh +++ b/regress/multiplex.sh | |||
@@ -1,10 +1,26 @@ | |||
1 | # $OpenBSD: multiplex.sh,v 1.21 2013/05/17 04:29:14 dtucker Exp $ | 1 | # $OpenBSD: multiplex.sh,v 1.25 2014/07/22 01:32:12 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | CTL=/tmp/openssh.regress.ctl-sock.$$ | 4 | CTL=/tmp/openssh.regress.ctl-sock.$$ |
5 | 5 | ||
6 | tid="connection multiplexing" | 6 | tid="connection multiplexing" |
7 | 7 | ||
8 | if have_prog nc ; then | ||
9 | if nc -h 2>&1 | grep -- -N >/dev/null; then | ||
10 | NC="nc -N"; | ||
11 | elif nc -h 2>&1 | grep -- "-U.*Use UNIX" >/dev/null ; then | ||
12 | NC="nc" | ||
13 | else | ||
14 | echo "nc is incompatible" | ||
15 | fi | ||
16 | fi | ||
17 | |||
18 | if test -z "$NC" ; then | ||
19 | echo "skipped (no compatible nc found)" | ||
20 | exit 0 | ||
21 | fi | ||
22 | |||
23 | trace "will use ProxyCommand $proxycmd" | ||
8 | if config_defined DISABLE_FD_PASSING ; then | 24 | if config_defined DISABLE_FD_PASSING ; then |
9 | echo "skipped (not supported on this platform)" | 25 | echo "skipped (not supported on this platform)" |
10 | exit 0 | 26 | exit 0 |
@@ -29,7 +45,8 @@ start_mux_master() | |||
29 | trace "start master, fork to background" | 45 | trace "start master, fork to background" |
30 | ${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost \ | 46 | ${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost \ |
31 | -E $TEST_REGRESS_LOGFILE 2>&1 & | 47 | -E $TEST_REGRESS_LOGFILE 2>&1 & |
32 | MASTER_PID=$! | 48 | # NB. $SSH_PID will be killed by test-exec.sh:cleanup on fatal errors. |
49 | SSH_PID=$! | ||
33 | wait_for_mux_master_ready | 50 | wait_for_mux_master_ready |
34 | } | 51 | } |
35 | 52 | ||
@@ -71,6 +88,25 @@ test -f ${COPY} || fail "scp: failed copy ${DATA}" | |||
71 | cmp ${DATA} ${COPY} || fail "scp: corrupted copy of ${DATA}" | 88 | cmp ${DATA} ${COPY} || fail "scp: corrupted copy of ${DATA}" |
72 | 89 | ||
73 | rm -f ${COPY} | 90 | rm -f ${COPY} |
91 | verbose "test $tid: forward" | ||
92 | trace "forward over TCP/IP and check result" | ||
93 | $NC -l 127.0.0.1 $((${PORT} + 1)) < ${DATA} & | ||
94 | netcat_pid=$! | ||
95 | ${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 | ||
96 | $NC -d 127.0.0.1 $((${PORT} + 2)) > ${COPY} < /dev/null | ||
97 | cmp ${DATA} ${COPY} || fail "ssh: corrupted copy of ${DATA}" | ||
98 | kill $netcat_pid 2>/dev/null | ||
99 | rm -f ${COPY} $OBJ/unix-[123].fwd | ||
100 | |||
101 | trace "forward over UNIX and check result" | ||
102 | $NC -Ul $OBJ/unix-1.fwd < ${DATA} & | ||
103 | netcat_pid=$! | ||
104 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L$OBJ/unix-2.fwd:$OBJ/unix-1.fwd otherhost >>$TEST_SSH_LOGFILE 2>&1 | ||
105 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -R$OBJ/unix-3.fwd:$OBJ/unix-2.fwd otherhost >>$TEST_SSH_LOGFILE 2>&1 | ||
106 | $NC -d -U $OBJ/unix-3.fwd > ${COPY} </dev/null | ||
107 | cmp ${DATA} ${COPY} || fail "ssh: corrupted copy of ${DATA}" | ||
108 | kill $netcat_pid 2>/dev/null | ||
109 | rm -f ${COPY} $OBJ/unix-[123].fwd | ||
74 | 110 | ||
75 | for s in 0 1 4 5 44; do | 111 | for s in 0 1 4 5 44; do |
76 | trace "exit status $s over multiplexed connection" | 112 | trace "exit status $s over multiplexed connection" |
@@ -95,7 +131,7 @@ verbose "test $tid: cmd check" | |||
95 | ${SSH} -F $OBJ/ssh_config -S $CTL -Ocheck otherhost >>$TEST_REGRESS_LOGFILE 2>&1 \ | 131 | ${SSH} -F $OBJ/ssh_config -S $CTL -Ocheck otherhost >>$TEST_REGRESS_LOGFILE 2>&1 \ |
96 | || fail "check command failed" | 132 | || fail "check command failed" |
97 | 133 | ||
98 | verbose "test $tid: cmd forward local" | 134 | verbose "test $tid: cmd forward local (TCP)" |
99 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L $P:localhost:$PORT otherhost \ | 135 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L $P:localhost:$PORT otherhost \ |
100 | || fail "request local forward failed" | 136 | || fail "request local forward failed" |
101 | ${SSH} -F $OBJ/ssh_config -p$P otherhost true \ | 137 | ${SSH} -F $OBJ/ssh_config -p$P otherhost true \ |
@@ -105,7 +141,7 @@ ${SSH} -F $OBJ/ssh_config -S $CTL -Ocancel -L $P:localhost:$PORT otherhost \ | |||
105 | ${SSH} -F $OBJ/ssh_config -p$P otherhost true \ | 141 | ${SSH} -F $OBJ/ssh_config -p$P otherhost true \ |
106 | && fail "local forward port still listening" | 142 | && fail "local forward port still listening" |
107 | 143 | ||
108 | verbose "test $tid: cmd forward remote" | 144 | verbose "test $tid: cmd forward remote (TCP)" |
109 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -R $P:localhost:$PORT otherhost \ | 145 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -R $P:localhost:$PORT otherhost \ |
110 | || fail "request remote forward failed" | 146 | || fail "request remote forward failed" |
111 | ${SSH} -F $OBJ/ssh_config -p$P otherhost true \ | 147 | ${SSH} -F $OBJ/ssh_config -p$P otherhost true \ |
@@ -115,13 +151,35 @@ ${SSH} -F $OBJ/ssh_config -S $CTL -Ocancel -R $P:localhost:$PORT otherhost \ | |||
115 | ${SSH} -F $OBJ/ssh_config -p$P otherhost true \ | 151 | ${SSH} -F $OBJ/ssh_config -p$P otherhost true \ |
116 | && fail "remote forward port still listening" | 152 | && fail "remote forward port still listening" |
117 | 153 | ||
154 | verbose "test $tid: cmd forward local (UNIX)" | ||
155 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L $OBJ/unix-1.fwd:localhost:$PORT otherhost \ | ||
156 | || fail "request local forward failed" | ||
157 | echo "" | $NC -U $OBJ/unix-1.fwd | grep "Protocol mismatch" >/dev/null 2>&1 \ | ||
158 | || fail "connect to local forward path failed" | ||
159 | ${SSH} -F $OBJ/ssh_config -S $CTL -Ocancel -L $OBJ/unix-1.fwd:localhost:$PORT otherhost \ | ||
160 | || fail "cancel local forward failed" | ||
161 | N=$(echo "xyzzy" | $NC -U $OBJ/unix-1.fwd 2>&1 | grep "xyzzy" | wc -l) | ||
162 | test ${N} -eq 0 || fail "local forward path still listening" | ||
163 | rm -f $OBJ/unix-1.fwd | ||
164 | |||
165 | verbose "test $tid: cmd forward remote (UNIX)" | ||
166 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -R $OBJ/unix-1.fwd:localhost:$PORT otherhost \ | ||
167 | || fail "request remote forward failed" | ||
168 | echo "" | $NC -U $OBJ/unix-1.fwd | grep "Protocol mismatch" >/dev/null 2>&1 \ | ||
169 | || fail "connect to remote forwarded path failed" | ||
170 | ${SSH} -F $OBJ/ssh_config -S $CTL -Ocancel -R $OBJ/unix-1.fwd:localhost:$PORT otherhost \ | ||
171 | || fail "cancel remote forward failed" | ||
172 | N=$(echo "xyzzy" | $NC -U $OBJ/unix-1.fwd 2>&1 | grep "xyzzy" | wc -l) | ||
173 | test ${N} -eq 0 || fail "remote forward path still listening" | ||
174 | rm -f $OBJ/unix-1.fwd | ||
175 | |||
118 | verbose "test $tid: cmd exit" | 176 | verbose "test $tid: cmd exit" |
119 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oexit otherhost >>$TEST_REGRESS_LOGFILE 2>&1 \ | 177 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oexit otherhost >>$TEST_REGRESS_LOGFILE 2>&1 \ |
120 | || fail "send exit command failed" | 178 | || fail "send exit command failed" |
121 | 179 | ||
122 | # Wait for master to exit | 180 | # Wait for master to exit |
123 | wait $MASTER_PID | 181 | wait $SSH_PID |
124 | kill -0 $MASTER_PID >/dev/null 2>&1 && fail "exit command failed" | 182 | kill -0 $SSH_PID >/dev/null 2>&1 && fail "exit command failed" |
125 | 183 | ||
126 | # Restart master and test -O stop command with master using -N | 184 | # Restart master and test -O stop command with master using -N |
127 | verbose "test $tid: cmd stop" | 185 | verbose "test $tid: cmd stop" |
@@ -138,6 +196,8 @@ ${SSH} -F $OBJ/ssh_config -S $CTL -Ostop otherhost >>$TEST_REGRESS_LOGFILE 2>&1 | |||
138 | # wait until both long-running command and master have exited. | 196 | # wait until both long-running command and master have exited. |
139 | wait $SLEEP_PID | 197 | wait $SLEEP_PID |
140 | [ $! != 0 ] || fail "waiting for concurrent command" | 198 | [ $! != 0 ] || fail "waiting for concurrent command" |
141 | wait $MASTER_PID | 199 | wait $SSH_PID |
142 | [ $! != 0 ] || fail "waiting for master stop" | 200 | [ $! != 0 ] || fail "waiting for master stop" |
143 | kill -0 $MASTER_PID >/dev/null 2>&1 && fail "stop command failed" | 201 | kill -0 $SSH_PID >/dev/null 2>&1 && fatal "stop command failed" |
202 | SSH_PID="" # Already gone, so don't kill in cleanup | ||
203 | |||