]>
Commit | Line | Data |
---|---|---|
00e612c7 | 1 | # $OpenBSD: multiplex.sh,v 1.4 2004/06/17 06:00:05 dtucker Exp $ |
00995aa0 | 2 | # Placed in the Public Domain. |
3 | ||
4 | CTL=$OBJ/ctl-sock | |
5 | ||
6 | tid="connection multiplexing" | |
7 | ||
00e612c7 | 8 | DATA=/bin/ls |
9 | COPY=$OBJ/ls.copy | |
10 | ||
00995aa0 | 11 | start_sshd |
12 | ||
13 | trace "start master, fork to background" | |
14 | ${SSH} -2 -MS$CTL -F $OBJ/ssh_config -f somehost sleep 60 | |
15 | ||
00e612c7 | 16 | rm -f ${COPY} |
00995aa0 | 17 | trace "ssh transfer over multiplexed connection and check result" |
00e612c7 | 18 | ${SSH} -S$CTL otherhost cat ${DATA} > ${COPY} |
19 | test -f ${COPY} || fail "failed copy ${DATA}" | |
20 | cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}" | |
00995aa0 | 21 | |
00e612c7 | 22 | rm -f ${COPY} |
00995aa0 | 23 | trace "ssh transfer over multiplexed connection and check result" |
00e612c7 | 24 | ${SSH} -S $CTL otherhost cat ${DATA} > ${COPY} |
25 | test -f ${COPY} || fail "failed copy ${DATA}" | |
26 | cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}" | |
00995aa0 | 27 | |
00e612c7 | 28 | rm -f ${COPY} |
00995aa0 | 29 | trace "sftp transfer over multiplexed connection and check result" |
00e612c7 | 30 | echo "get ${DATA} ${COPY}" | \ |
6d3d1404 | 31 | ${SFTP} -oControlPath=$CTL otherhost >/dev/null 2>&1 |
00e612c7 | 32 | test -f ${COPY} || fail "failed copy ${DATA}" |
33 | cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}" | |
00995aa0 | 34 | |
00e612c7 | 35 | rm -f ${COPY} |
00995aa0 | 36 | trace "scp transfer over multiplexed connection and check result" |
00e612c7 | 37 | ${SCP} -oControlPath=$CTL otherhost:${DATA} ${COPY} >/dev/null 2>&1 |
38 | test -f ${COPY} || fail "failed copy ${DATA}" | |
39 | cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}" | |
00995aa0 | 40 | |
00e612c7 | 41 | rm -f ${COPY} |
58766d34 | 42 | |
00995aa0 | 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 | |
47 | r=$? | |
48 | if [ $r -ne $s ]; then | |
49 | fail "exit code mismatch for protocol $p: $r != $s" | |
50 | fi | |
51 | ||
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"\' | |
56 | r=$? | |
57 | if [ $r -ne $s ]; then | |
58 | fail "exit code (with sleep) mismatch for protocol $p: $r != $s" | |
59 | fi | |
60 | done | |
61 | ||
58766d34 | 62 | # kill master, remove control socket. ssh -MS will exit when sleep exits |
63 | $SUDO kill `cat $PIDFILE` | |
64 | rm -f $CTL |