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