]>
Commit | Line | Data |
---|---|---|
a1c3731b | 1 | # $OpenBSD: multiplex.sh,v 1.9 2004/11/07 00:32:41 djm Exp $ |
00995aa0 | 2 | # Placed in the Public Domain. |
3 | ||
4 | CTL=$OBJ/ctl-sock | |
5 | ||
6 | tid="connection multiplexing" | |
7 | ||
3b4e535d | 8 | if grep "#define.*DISABLE_FD_PASSING" ${BUILDDIR}/config.h >/dev/null 2>&1 |
9 | then | |
10 | echo "skipped (not supported on this platform)" | |
11 | exit 0 | |
12 | fi | |
13 | ||
b066fabe | 14 | DATA=/bin/ls${EXEEXT} |
00e612c7 | 15 | COPY=$OBJ/ls.copy |
16 | ||
00995aa0 | 17 | start_sshd |
18 | ||
19 | trace "start master, fork to background" | |
a1c3731b | 20 | ${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost & |
21 | MASTER_PID=$! | |
22 | ||
23 | # Wait for master to start and authenticate | |
24 | sleep 5 | |
00995aa0 | 25 | |
b9a59b74 | 26 | verbose "test $tid: envpass" |
27 | trace "env passing over multiplexed connection" | |
cb19b709 | 28 | _XXX_TEST=blah ${SSH} -oSendEnv="_XXX_TEST" -S$CTL otherhost sh << 'EOF' |
29 | test X"$_XXX_TEST" = X"blah" | |
30 | EOF | |
b9a59b74 | 31 | if [ $? -ne 0 ]; then |
32 | fail "environment not found" | |
33 | fi | |
34 | ||
35 | verbose "test $tid: transfer" | |
00e612c7 | 36 | rm -f ${COPY} |
00995aa0 | 37 | trace "ssh transfer over multiplexed connection and check result" |
00e612c7 | 38 | ${SSH} -S$CTL otherhost cat ${DATA} > ${COPY} |
c031f95b | 39 | test -f ${COPY} || fail "ssh -Sctl: failed copy ${DATA}" |
40 | cmp ${DATA} ${COPY} || fail "ssh -Sctl: corrupted copy of ${DATA}" | |
00995aa0 | 41 | |
00e612c7 | 42 | rm -f ${COPY} |
00995aa0 | 43 | trace "ssh transfer over multiplexed connection and check result" |
00e612c7 | 44 | ${SSH} -S $CTL otherhost cat ${DATA} > ${COPY} |
c031f95b | 45 | test -f ${COPY} || fail "ssh -S ctl: failed copy ${DATA}" |
46 | cmp ${DATA} ${COPY} || fail "ssh -S ctl: corrupted copy of ${DATA}" | |
00995aa0 | 47 | |
00e612c7 | 48 | rm -f ${COPY} |
00995aa0 | 49 | trace "sftp transfer over multiplexed connection and check result" |
00e612c7 | 50 | echo "get ${DATA} ${COPY}" | \ |
1980d5c9 | 51 | ${SFTP} -S ${SSH} -oControlPath=$CTL otherhost >/dev/null 2>&1 |
c031f95b | 52 | test -f ${COPY} || fail "sftp: failed copy ${DATA}" |
53 | cmp ${DATA} ${COPY} || fail "sftp: corrupted copy of ${DATA}" | |
00995aa0 | 54 | |
00e612c7 | 55 | rm -f ${COPY} |
00995aa0 | 56 | trace "scp transfer over multiplexed connection and check result" |
1980d5c9 | 57 | ${SCP} -S ${SSH} -oControlPath=$CTL otherhost:${DATA} ${COPY} >/dev/null 2>&1 |
c031f95b | 58 | test -f ${COPY} || fail "scp: failed copy ${DATA}" |
59 | cmp ${DATA} ${COPY} || fail "scp: corrupted copy of ${DATA}" | |
00995aa0 | 60 | |
00e612c7 | 61 | rm -f ${COPY} |
58766d34 | 62 | |
00995aa0 | 63 | for s in 0 1 4 5 44; do |
64 | trace "exit status $s over multiplexed connection" | |
65 | verbose "test $tid: status $s" | |
66 | ${SSH} -S $CTL otherhost exit $s | |
67 | r=$? | |
68 | if [ $r -ne $s ]; then | |
69 | fail "exit code mismatch for protocol $p: $r != $s" | |
70 | fi | |
71 | ||
72 | # same with early close of stdout/err | |
73 | trace "exit status $s with early close over multiplexed connection" | |
74 | ${SSH} -S $CTL -n otherhost \ | |
75 | exec sh -c \'"sleep 2; exec > /dev/null 2>&1; sleep 3; exit $s"\' | |
76 | r=$? | |
77 | if [ $r -ne $s ]; then | |
78 | fail "exit code (with sleep) mismatch for protocol $p: $r != $s" | |
79 | fi | |
80 | done | |
81 | ||
a1c3731b | 82 | trace "test check command" |
83 | ${SSH} -S $CTL -Ocheck otherhost || fail "check command failed" | |
84 | ||
85 | trace "test exit command" | |
86 | ${SSH} -S $CTL -Oexit otherhost || fail "send exit command failed" | |
87 | ||
88 | # Wait for master to exit | |
89 | sleep 2 | |
90 | ||
91 | ps -p $MASTER_PID >/dev/null && fail "exit command failed" | |
92 | ||
93 | cleanup |