1 # $OpenBSD: multiplex.sh,v 1.5 2004/06/17 06:19:06 dtucker Exp $
2 # Placed in the Public Domain.
6 tid="connection multiplexing"
13 trace "start master, fork to background"
14 ${SSH} -2 -MS$CTL -F $OBJ/ssh_config -f somehost sleep 60
17 trace "ssh transfer over multiplexed connection and check result"
18 ${SSH} -S$CTL otherhost cat ${DATA} > ${COPY}
19 test -f ${COPY} || fail "ssh -Sctl: failed copy ${DATA}"
20 cmp ${DATA} ${COPY} || fail "ssh -Sctl: corrupted copy of ${DATA}"
23 trace "ssh transfer over multiplexed connection and check result"
24 ${SSH} -S $CTL otherhost cat ${DATA} > ${COPY}
25 test -f ${COPY} || fail "ssh -S ctl: failed copy ${DATA}"
26 cmp ${DATA} ${COPY} || fail "ssh -S ctl: corrupted copy of ${DATA}"
29 trace "sftp transfer over multiplexed connection and check result"
30 echo "get ${DATA} ${COPY}" | \
31 ${SFTP} -oControlPath=$CTL otherhost >/dev/null 2>&1
32 test -f ${COPY} || fail "sftp: failed copy ${DATA}"
33 cmp ${DATA} ${COPY} || fail "sftp: corrupted copy of ${DATA}"
36 trace "scp transfer over multiplexed connection and check result"
37 ${SCP} -oControlPath=$CTL otherhost:${DATA} ${COPY} >/dev/null 2>&1
38 test -f ${COPY} || fail "scp: failed copy ${DATA}"
39 cmp ${DATA} ${COPY} || fail "scp: corrupted copy of ${DATA}"
43 for s in 0 1 4 5 44; do
44 trace "exit status $s over multiplexed connection"
45 verbose "test $tid: status $s"
46 ${SSH} -S $CTL otherhost exit $s
48 if [ $r -ne $s ]; then
49 fail "exit code mismatch for protocol $p: $r != $s"
52 # same with early close of stdout/err
53 trace "exit status $s with early close over multiplexed connection"
54 ${SSH} -S $CTL -n otherhost \
55 exec sh -c \'"sleep 2; exec > /dev/null 2>&1; sleep 3; exit $s"\'
57 if [ $r -ne $s ]; then
58 fail "exit code (with sleep) mismatch for protocol $p: $r != $s"
62 # kill master, remove control socket. ssh -MS will exit when sleep exits
63 $SUDO kill `cat $PIDFILE`