Skip to content

Commit cef2593

Browse files
committed
upstream: regression test for UnusedConnectionTimeout
OpenBSD-Regress-ID: 7f29001374a68e71e5e078f69e4520cf4bcca084
1 parent aff9493 commit cef2593

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

regress/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ LTESTS= connect \
102102
knownhosts-command \
103103
agent-restrict \
104104
hostbased \
105-
channel-timeout
105+
channel-timeout \
106+
connection-timeout
106107

107108
INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers
108109
#INTEROP_TESTS+=ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp

regress/connection-timeout.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# $OpenBSD: connection-timeout.sh,v 1.1 2023/01/17 10:02:34 djm Exp $
2+
# Placed in the Public Domain.
3+
4+
tid="unused connection timeout"
5+
6+
CTL=$OBJ/ctl-sock
7+
cp $OBJ/sshd_proxy $OBJ/sshd_proxy.orig
8+
9+
check_ssh() {
10+
test -S $CTL || return 1
11+
if ! ${REAL_SSH} -qF$OBJ/ssh_proxy -O check \
12+
-oControlPath=$CTL somehost >/dev/null 2>&1 ; then
13+
return 1
14+
fi
15+
return 0
16+
}
17+
18+
start_ssh() {
19+
trace "start ssh"
20+
${SSH} -nNfF $OBJ/ssh_proxy "$@" -oExitOnForwardFailure=yes \
21+
-oControlMaster=yes -oControlPath=$CTL somehost
22+
r=$?
23+
test $r -eq 0 || fatal "failed to start ssh $r"
24+
check_ssh || fatal "ssh process unresponsive"
25+
}
26+
27+
stop_ssh() {
28+
test -S $CTL || return
29+
check_ssh || fatal "ssh process is unresponsive: cannot close"
30+
if ! ${REAL_SSH} -qF$OBJ/ssh_proxy -O exit \
31+
-oControlPath=$CTL >/dev/null somehost >/dev/null ; then
32+
fatal "ssh process did not respond to close"
33+
fi
34+
n=0
35+
while [ "$n" -lt 20 ] ; do
36+
test -S $CTL || break
37+
sleep 1
38+
n=`expr $n + 1`
39+
done
40+
if test -S $CTL ; then
41+
fatal "ssh process did not exit"
42+
fi
43+
}
44+
45+
trap "stop_ssh" EXIT
46+
47+
verbose "no timeout"
48+
start_ssh
49+
sleep 5
50+
check_ssh || fatal "ssh unexpectedly missing"
51+
stop_ssh
52+
53+
(cat $OBJ/sshd_proxy.orig ; echo "UnusedConnectionTimeout 2") > $OBJ/sshd_proxy
54+
55+
verbose "timeout"
56+
start_ssh
57+
sleep 8
58+
check_ssh && fail "ssh unexpectedly present"
59+
stop_ssh
60+
61+
verbose "timeout after session"
62+
start_ssh
63+
${REAL_SSH} -qoControlPath=$CTL -oControlMaster=no -Fnone somehost "exit 0" ||
64+
fail "session failed"
65+
sleep 8
66+
check_ssh && fail "ssh unexpectedly present"
67+
stop_ssh
68+
69+
LPORT=`expr $PORT + 1`
70+
RPORT=`expr $LPORT + 1`
71+
DPORT=`expr $RPORT + 1`
72+
RDPORT=`expr $DPORT + 1`
73+
verbose "timeout with listeners"
74+
start_ssh -L$LPORT:127.0.0.1:$PORT -R$RPORT:127.0.0.1:$PORT -D$DPORT -R$RDPORT
75+
sleep 8
76+
check_ssh && fail "ssh unexpectedly present"
77+
stop_ssh

0 commit comments

Comments
 (0)