mirror of
https://github.com/openssh/openssh-portable.git
synced 2026-01-12 00:04:08 +08:00
upstream: add a "ssh -O channels user@host" multiplexing command to
get a running mux process to show information about what channels are currently open; ok dtucker@ markus@ OpenBSD-Commit-ID: 80bb3953b306a50839f9a4bc5679faebc32e5bb8
This commit is contained in:
committed by
Damien Miller
parent
b652322cdc
commit
daf6bdd34b
@@ -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 *);
|
||||
|
||||
21
mux.c
21
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);
|
||||
|
||||
6
ssh.1
6
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
|
||||
|
||||
4
ssh.c
4
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)
|
||||
|
||||
Reference in New Issue
Block a user