[openssh-commits] [openssh] 03/03: upstream: extend ChannelTimeout regression test to exercise multiplexed

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Jan 10 09:25:16 AEDT 2024


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 9707c8170c0c1baeb1e06e5a53f604498193885f
Author: djm at openbsd.org <djm at openbsd.org>
Date:   Tue Jan 9 22:19:36 2024 +0000

    upstream: extend ChannelTimeout regression test to exercise multiplexed
    
    connections and the new "global" timeout type. ok dtucker@
    
    OpenBSD-Regress-ID: f10d19f697024e9941acad7c2057f73d6eacb8a2
---
 regress/channel-timeout.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 68 insertions(+), 2 deletions(-)

diff --git a/regress/channel-timeout.sh b/regress/channel-timeout.sh
index 1c42e832..4293f017 100644
--- a/regress/channel-timeout.sh
+++ b/regress/channel-timeout.sh
@@ -1,10 +1,33 @@
-#	$OpenBSD: channel-timeout.sh,v 1.1 2023/01/06 08:07:39 djm Exp $
+#	$OpenBSD: channel-timeout.sh,v 1.2 2024/01/09 22:19:36 djm Exp $
 #	Placed in the Public Domain.
 
 tid="channel timeout"
 
 # XXX not comprehensive. Still need -R -L agent X11 forwarding + interactive
 
+rm -f $OBJ/finished.* $OBJ/mux.*
+
+MUXPATH=$OBJ/mux.$$
+open_mux() {
+	${SSH} -nNfM -oControlPath=$MUXPATH -F $OBJ/ssh_proxy "$@" somehost ||
+	    fatal "open mux failed"
+	test -e $MUXPATH || fatal "mux socket $MUXPATH not established"
+}
+
+close_mux() {
+	test -e $MUXPATH || fatal "mux socket $MUXPATH missing"
+	${SSH} -qF $OBJ/ssh_proxy -oControlPath=$MUXPATH -O exit somehost ||
+	    fatal "could not terminate mux process"
+	for x in 1 2 3 4 5 6 7 8 9 10 ; do
+		test -e $OBJ/mux && break
+		sleep 1
+	done
+	test -e $MUXPATH && fatal "mux did not clean up"
+}
+mux_client() {
+	${SSH} -F $OBJ/ssh_proxy -oControlPath=$MUXPATH somehost "$@"
+}
+
 rm -f $OBJ/sshd_proxy.orig 
 cp $OBJ/sshd_proxy $OBJ/sshd_proxy.orig
 
@@ -24,6 +47,15 @@ if [ $r -ne 255 ]; then
 	fail "ssh returned unexpected error code $r"
 fi
 
+verbose "command long timeout"
+(cat $OBJ/sshd_proxy.orig ; echo "ChannelTimeout session:command=60") \
+	> $OBJ/sshd_proxy
+${SSH} -F $OBJ/ssh_proxy somehost "exit 23"
+r=$?
+if [ $r -ne 23 ]; then
+	fail "ssh returned unexpected error code $r"
+fi
+
 verbose "command wildcard timeout"
 (cat $OBJ/sshd_proxy.orig ; echo "ChannelTimeout session:*=1") \
 	> $OBJ/sshd_proxy
@@ -42,6 +74,41 @@ if [ $r -ne 23 ]; then
 	fail "ssh failed"
 fi
 
+verbose "multiplexed command timeout"
+(cat $OBJ/sshd_proxy.orig ; echo "ChannelTimeout session:command=1") \
+	> $OBJ/sshd_proxy
+open_mux
+mux_client "sleep 5 ; exit 23"
+r=$?
+if [ $r -ne 255 ]; then
+	fail "ssh returned unexpected error code $r"
+fi
+close_mux
+
+verbose "irrelevant multiplexed command timeout"
+(cat $OBJ/sshd_proxy.orig ; echo "ChannelTimeout session:shell=1") \
+	> $OBJ/sshd_proxy
+open_mux
+mux_client "sleep 5 ; exit 23"
+r=$?
+if [ $r -ne 23 ]; then
+	fail "ssh returned unexpected error code $r"
+fi
+close_mux
+
+verbose "global command timeout"
+(cat $OBJ/sshd_proxy.orig ; echo "ChannelTimeout global=10") \
+	> $OBJ/sshd_proxy
+open_mux
+mux_client "sleep 1 ; echo ok ; sleep 1; echo ok; sleep 60; touch $OBJ/finished.1" >/dev/null &
+mux_client "sleep 60 ; touch $OBJ/finished.2" >/dev/null &
+mux_client "sleep 2 ; touch $OBJ/finished.3" >/dev/null &
+wait
+test -f $OBJ/finished.1 && fail "first mux process completed"
+test -f $OBJ/finished.2 && fail "second mux process completed"
+test -f $OBJ/finished.3 || fail "third mux process did not complete"
+close_mux
+
 # Set up a "slow sftp server" that sleeps before executing the real one.
 cat > $OBJ/slow-sftp-server.sh << _EOF
 #!/bin/sh
@@ -88,4 +155,3 @@ if [ $r -ne 0 ]; then
 	fail "sftp failed"
 fi
 cmp $DATA $COPY || fail "corrupted copy"
-

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list