[openssh-commits] [openssh] branch master updated: upstream: Fix ChannelTimeout specificity

git+noreply at mindrot.org git+noreply at mindrot.org
Tue Sep 15 16:09:49 AEST 2026


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

djm pushed a commit to branch master
in repository openssh.

The following commit(s) were added to refs/heads/master by this push:
     new 02cf3c2bd upstream: Fix ChannelTimeout specificity
02cf3c2bd is described below

commit 02cf3c2bd6150c359b0da8f1e25994e4e9214d3f
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Tue Sep 15 06:05:47 2026 +0000

    upstream: Fix ChannelTimeout specificity
    
    Previously a more specific channel type (e.g. "session:shell") could
    clobber a user-specified ChannelTimeout if it was less specific
    (e.g. "session").
    
    Also, in some cases, the debug messages were printing 0 instead of the
    effective timeout.
    
    From Bhagavathiyappan Shanmugam <Bhagavathiyappan.Shanmugam at ibm.com>
    via bz3994
    
    OpenBSD-Commit-ID: ba88e80db4957b98dfc0cc3b93a8d6d34e18d32d
---
 channels.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/channels.c b/channels.c
index 56020d879..262791301 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: channels.c,v 1.464 2026/09/14 02:38:27 djm Exp $ */
+/* $OpenBSD: channels.c,v 1.465 2026/09/15 06:05:47 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -378,6 +378,7 @@ channel_classify(struct ssh *ssh, Channel *c)
 void
 channel_set_xtype(struct ssh *ssh, int id, const char *xctype)
 {
+	struct ssh_channels *sc = ssh->chanctxt;
 	Channel *c;
 
 	if ((c = channel_by_id(ssh, id)) == NULL)
@@ -385,11 +386,15 @@ channel_set_xtype(struct ssh *ssh, int id, const char *xctype)
 	if (c->xctype != NULL)
 		free(c->xctype);
 	c->xctype = xstrdup(xctype);
-	/* Type has changed, so look up inactivity deadline again */
-	c->inactive_deadline = lookup_timeout(ssh, c->xctype);
+	/* Only override deadline if xctype has a more specific match. */
+	int xtype_deadline = lookup_timeout(ssh, c->xctype);
+	if (xtype_deadline != 0)
+		c->inactive_deadline = xtype_deadline;
 	channel_classify(ssh, c);
+	/* report effective timeout: per-channel if set, else global */
 	debug2_f("labeled channel %d as %s (inactive timeout %u)", id, xctype,
-	    c->inactive_deadline);
+	    c->inactive_deadline != 0 ? c->inactive_deadline
+	    : (u_int)sc->global_deadline);
 }
 
 /*
@@ -560,7 +565,9 @@ channel_new(struct ssh *ssh, char *ctype, int type, int rfd, int wfd, int efd,
 	TAILQ_INIT(&c->status_confirms);
 	channel_classify(ssh, c);
 	debug("channel %d: new %s [%s] (inactive timeout: %u)",
-	    found, c->ctype, remote_name, c->inactive_deadline);
+	    found, c->ctype, remote_name,
+	    c->inactive_deadline != 0 ? c->inactive_deadline
+	    : (u_int)sc->global_deadline);
 	return c;
 }
 
@@ -2708,9 +2715,11 @@ channel_handler(struct ssh *ssh, int table, struct timespec *timeout)
 			    channel_get_expiry(ssh, c) != 0 &&
 			    now >= channel_get_expiry(ssh, c)) {
 				/* channel closed for inactivity */
+				u_int fired_deadline = c->inactive_deadline != 0
+				    ? c->inactive_deadline
+				    : (u_int)sc->global_deadline;
 				verbose("channel %d: closing after %u seconds "
-				    "of inactivity", c->self,
-				    c->inactive_deadline);
+				    "of inactivity", c->self, fired_deadline);
 				channel_force_close(ssh, c, 1);
 			} else if (c->notbefore <= now) {
 				/* Run handlers that are not paused. */

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


More information about the openssh-commits mailing list