]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: add a "ssh -O channels user@host" multiplexing command to
authordjm@openbsd.org <djm@openbsd.org>
Mon, 22 Dec 2025 01:17:31 +0000 (01:17 +0000)
committerDamien Miller <djm@mindrot.org>
Mon, 22 Dec 2025 01:51:22 +0000 (12:51 +1100)
get a running mux process to show information about what channels are
currently open; ok dtucker@ markus@

OpenBSD-Commit-ID: 80bb3953b306a50839f9a4bc5679faebc32e5bb8

clientloop.h
mux.c
ssh.1
ssh.c

index 1f550b35cd1e9da94a18afc38283b886e4be9d5d..a2dc8758c265a0aa430b99fb2579a9267fb47a8c 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: clientloop.h,v 1.39 2025/12/05 06:16:27 dtucker Exp $ */
+/* $OpenBSD: clientloop.h,v 1.40 2025/12/22 01:17:31 djm Exp $ */
 
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -76,6 +76,7 @@ void client_expect_confirm(struct ssh *, int, const char *,
 #define SSHMUX_COMMAND_CANCEL_FWD      7       /* Cancel forwarding(s) */
 #define SSHMUX_COMMAND_PROXY           8       /* Open new connection */
 #define SSHMUX_COMMAND_CONNINFO                9       /* Show connection information */
+#define SSHMUX_COMMAND_CHANINFO                10      /* Show channels information */
 
 void   muxserver_listen(struct ssh *);
 int    muxclient(const char *);
diff --git a/mux.c b/mux.c
index 53cbab0fc87dd271e1f4ff9518b387a206f6faa8..bbeb505b46d83ba1f7042d2efe852e8a48854343 100644 (file)
--- a/mux.c
+++ b/mux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mux.c,v 1.108 2025/12/05 06:16:27 dtucker Exp $ */
+/* $OpenBSD: mux.c,v 1.109 2025/12/22 01:17:31 djm Exp $ */
 /*
  * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org>
  *
@@ -527,6 +527,10 @@ mux_master_process_ext_info(struct ssh *ssh, u_int rid,
                if ((msg = connection_info_message(ssh)) == NULL)
                        fatal_f("connection_info_message");
                status = 1;
+       } else if (strcmp(name, "channels") == 0) {
+               if ((msg = channel_open_message(ssh)) == NULL)
+                       fatal_f("channel_open_message");
+               status = 1;
        } else {
                msg = xstrdup("info request type not supported");
        }
@@ -2369,7 +2373,7 @@ muxclient(const char *path)
        struct sockaddr_un addr;
        int sock, timeout = options.connection_timeout, timeout_ms = -1;
        u_int pid;
-       char *conninfo = NULL;
+       char *info = NULL;
 
        if (muxclient_command == 0) {
                if (options.stdio_forward_host != NULL)
@@ -2441,12 +2445,15 @@ muxclient(const char *path)
                fprintf(stderr, "Master running (pid=%u)\r\n", pid);
                exit(0);
        case SSHMUX_COMMAND_CONNINFO:
+       case SSHMUX_COMMAND_CHANINFO:
                if (!(extensions & MUX_EXT_INFO))
-                       fatal("mux server does not support conninfo");
-               conninfo = mux_client_request_info(sock, "connection");
-               if (conninfo == NULL)
-                       fatal_f("connection info request failed");
-               printf("%s", conninfo);
+                       fatal("mux server does not support info request");
+               info = mux_client_request_info(sock,
+                   muxclient_command == SSHMUX_COMMAND_CONNINFO ?
+                   "connection" : "channels");
+               if (info == NULL)
+                       fatal_f("info request failed");
+               printf("%s", info);
                exit(0);
        case SSHMUX_COMMAND_TERMINATE:
                mux_client_request_terminate(sock);
diff --git a/ssh.1 b/ssh.1
index ac218cc513403f09c2835ed30a3e02b26ebd2300..82ae5480c3ee8e900f84b8a00f4c34d1c2d0c366 100644 (file)
--- a/ssh.1
+++ b/ssh.1
@@ -33,8 +33,8 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $OpenBSD: ssh.1,v 1.446 2025/12/05 06:16:27 dtucker Exp $
-.Dd $Mdocdate: December 5 2025 $
+.\" $OpenBSD: ssh.1,v 1.447 2025/12/22 01:17:31 djm Exp $
+.Dd $Mdocdate: December 22 2025 $
 .Dt SSH 1
 .Os
 .Sh NAME
@@ -488,6 +488,8 @@ Valid commands are:
 (check that the master process is running),
 .Dq conninfo
 (report information about the master connection),
+.Dq channels
+(report information about open channels),
 .Dq forward
 (request forwardings without command execution),
 .Dq cancel
diff --git a/ssh.c b/ssh.c
index 461b60975b1aac153918362a7397ddf11aeb70b0..0b1a6e158fac50ca9c27c796ce541f4310f11a1b 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.c,v 1.621 2025/12/05 06:16:27 dtucker Exp $ */
+/* $OpenBSD: ssh.c,v 1.622 2025/12/22 01:17:31 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -819,6 +819,8 @@ main(int ac, char **av)
                                muxclient_command = SSHMUX_COMMAND_ALIVE_CHECK;
                        else if (strcmp(optarg, "conninfo") == 0)
                                muxclient_command = SSHMUX_COMMAND_CONNINFO;
+                       else if (strcmp(optarg, "channels") == 0)
+                               muxclient_command = SSHMUX_COMMAND_CHANINFO;
                        else if (strcmp(optarg, "forward") == 0)
                                muxclient_command = SSHMUX_COMMAND_FORWARD;
                        else if (strcmp(optarg, "exit") == 0)