1 # $OpenBSD: multiplex.sh,v 1.3 2004/06/17 05:51:59 dtucker Exp $
2 # Placed in the Public Domain.
6 tid="connection multiplexing"
10 trace "start master, fork to background"
11 ${SSH} -2 -MS$CTL -F $OBJ/ssh_config -f somehost sleep 60
14 trace "ssh transfer over multiplexed connection and check result"
15 ${SSH} -S$CTL otherhost cat /bin/ls > $OBJ/ls.copy
16 test -f $OBJ/ls.copy || fail "failed copy /bin/ls"
17 cmp /bin/ls $OBJ/ls.copy || fail "corrupted copy of /bin/ls"
20 trace "ssh transfer over multiplexed connection and check result"
21 ${SSH} -S $CTL otherhost cat /bin/ls > $OBJ/ls.copy
22 test -f $OBJ/ls.copy || fail "failed copy /bin/ls"
23 cmp /bin/ls $OBJ/ls.copy || fail "corrupted copy of /bin/ls"
26 trace "sftp transfer over multiplexed connection and check result"
27 echo "get /bin/ls $OBJ/ls.copy" | \
28 ${SFTP} -oControlPath=$CTL otherhost >/dev/null 2>&1
29 test -f $OBJ/ls.copy || fail "failed copy /bin/ls"
30 cmp /bin/ls $OBJ/ls.copy || fail "corrupted copy of /bin/ls"
33 trace "scp transfer over multiplexed connection and check result"
34 ${SCP} -oControlPath=$CTL otherhost:/bin/ls $OBJ/ls.copy >/dev/null 2>&1
35 test -f $OBJ/ls.copy || fail "failed copy /bin/ls"
36 cmp /bin/ls $OBJ/ls.copy || fail "corrupted copy of /bin/ls"
40 for s in 0 1 4 5 44; do
41 trace "exit status $s over multiplexed connection"
42 verbose "test $tid: status $s"
43 ${SSH} -S $CTL otherhost exit $s
45 if [ $r -ne $s ]; then
46 fail "exit code mismatch for protocol $p: $r != $s"
49 # same with early close of stdout/err
50 trace "exit status $s with early close over multiplexed connection"
51 ${SSH} -S $CTL -n otherhost \
52 exec sh -c \'"sleep 2; exec > /dev/null 2>&1; sleep 3; exit $s"\'
54 if [ $r -ne $s ]; then
55 fail "exit code (with sleep) mismatch for protocol $p: $r != $s"
59 # kill master, remove control socket. ssh -MS will exit when sleep exits
60 $SUDO kill `cat $PIDFILE`