Bugzilla – Attachment 1708 Details for
Bug 1664
add support for tagging session channels with friendly names and add "ps" control command
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
adds support for the ps command and passing the slave pid through the mux channel when requesting a new session
openssh-cmd-ps-0.patch (text/plain), 5.15 KB, created by
Salvador Fandiño
on 2009-10-25 22:06:38 AEDT
(
hide
)
Description:
adds support for the ps command and passing the slave pid through the mux channel when requesting a new session
Filename:
MIME Type:
Creator:
Salvador Fandiño
Created:
2009-10-25 22:06:38 AEDT
Size:
5.15 KB
patch
obsolete
>diff --git a/channels.c b/channels.c >index 6ef400c..4696c60 100644 >--- a/channels.c >+++ b/channels.c >@@ -184,6 +184,20 @@ channel_by_id(int id) > return c; > } > >+/* Iterate over channels >+ * Use as: for (c = NULL; c = next_channel(c); ) ... >+ */ >+Channel * >+channel_next(Channel *current) >+{ >+ int id = (current ? current->self + 1 : 0); >+ for (; id < channels_alloc; id++) { >+ Channel *c = channels[id]; >+ if (c) return c; >+ } >+ return NULL; >+} >+ > /* > * Returns the channel if it is allowed to receive protocol messages. > * Private channels, like listening sockets, may not receive messages. >diff --git a/channels.h b/channels.h >index 8739cef..c31bb1b 100644 >--- a/channels.h >+++ b/channels.h >@@ -186,6 +186,7 @@ struct Channel { > /* channel management */ > > Channel *channel_by_id(int); >+Channel *channel_next(Channel *); > Channel *channel_lookup(int); > Channel *channel_new(char *, int, int, int, int, u_int, u_int, int, char *, int); > void channel_set_fds(int, int, int, int, int, int, int, u_int); >diff --git a/clientloop.h b/clientloop.h >index 67b7415..c961abd 100644 >--- a/clientloop.h >+++ b/clientloop.h >@@ -56,12 +56,13 @@ typedef void global_confirm_cb(int, u_int32_t seq, void *); > void client_register_global_confirm(global_confirm_cb *, void *); > > /* Multiplexing protocol version */ >-#define SSHMUX_VER 2 >+#define SSHMUX_VER 3 > > /* Multiplexing control protocol flags */ > #define SSHMUX_COMMAND_OPEN 1 /* Open new connection */ > #define SSHMUX_COMMAND_ALIVE_CHECK 2 /* Check master is alive */ > #define SSHMUX_COMMAND_TERMINATE 3 /* Ask master to exit */ >+#define SSHMUX_COMMAND_PS 4 /* Get list of slaves */ > > #define SSHMUX_FLAG_TTY (1) /* Request tty on open */ > #define SSHMUX_FLAG_SUBSYS (1<<1) /* Subsystem request on open */ >diff --git a/mux.c b/mux.c >index 36cd348..e78c88e 100644 >--- a/mux.c >+++ b/mux.c >@@ -208,11 +208,11 @@ muxserver_accept_control(void) > { > Buffer m; > Channel *c; >- int client_fd, new_fd[3], ver, allowed, window, packetmax, ask; >+ int client_fd, new_fd[3], ver, allowed, window, packetmax, ask, count; > socklen_t addrlen; > struct sockaddr_storage addr; > struct mux_session_confirm_ctx *cctx; >- char *cmd; >+ char *cmd, *tag; > u_int i, j, len, env_len, mux_command, flags, escape_char; > uid_t euid; > gid_t egid; >@@ -293,6 +293,18 @@ muxserver_accept_control(void) > if (allowed) > start_close = 1; > break; >+ >+ case SSHMUX_COMMAND_PS: >+ count = 0; >+ c = NULL; >+ while (c = channel_next(c)) >+ if (c->tag) >+ count ++; >+ buffer_put_int(&m, count); >+ while (c = channel_next(c)) >+ if (c->tag) >+ buffer_put_cstring(&m, c->tag); >+ break; > default: > error("Unsupported command %d", mux_command); > goto cleanup; >@@ -335,6 +347,7 @@ muxserver_accept_control(void) > cctx->want_agent_fwd = (flags & SSHMUX_FLAG_AGENT_FWD) != 0; > cctx->term = buffer_get_string(&m, &len); > escape_char = buffer_get_int(&m); >+ tag = buffer_get_string(&m, &len); > > cmd = buffer_get_string(&m, &len); > buffer_init(&cctx->cmd); >@@ -369,6 +382,7 @@ muxserver_accept_control(void) > buffer_free(&cctx->cmd); > close(client_fd); > xfree(cctx); >+ xfree(tag); > return 0; > } > } >@@ -395,6 +409,8 @@ muxserver_accept_control(void) > xfree(cctx->env[i]); > xfree(cctx->env); > } >+ xfree(cctx); >+ xfree(tag); > return 0; > } > buffer_free(&m); >@@ -421,6 +437,7 @@ muxserver_accept_control(void) > CHAN_EXTENDED_WRITE, "client-session", /*nonblock*/0); > > c->ctl_fd = client_fd; >+ c->tag = tag; > if (cctx->want_tty && escape_char != 0xffffffff) { > channel_register_filter(c->self, > client_simple_escape_filter, NULL, >@@ -484,9 +501,9 @@ void > muxclient(const char *path, int ac, char **av) > { > struct sockaddr_un addr; >- int i, r, fd, sock, exitval[2], num_env; >+ int i, r, fd, sock, exitval[2], num_env, count, len; > Buffer m; >- char *term; >+ char *term, *tag = NULL; > extern char **environ; > u_int allowed, flags; > >@@ -617,6 +634,21 @@ muxclient(const char *path, int ac, char **av) > case SSHMUX_COMMAND_TERMINATE: > fprintf(stderr, "Exit request sent.\r\n"); > exit(0); >+ case SSHMUX_COMMAND_PS: >+ if (buffer_get_int_ret(&count, &m) != 0) { >+ error("%s: bad server reply", __func__); >+ goto muxerr; >+ } >+ for (i = 0; i < count; i++) { >+ tag = buffer_get_string(&m, &len); >+ if (!tag) { >+ error("%s: bad server reply", __func__); >+ goto muxerr; >+ } >+ printf("%s\n", tag); >+ xfree(tag); >+ } >+ exit(0); > case SSHMUX_COMMAND_OPEN: > buffer_clear(&m); > buffer_put_cstring(&m, term ? term : ""); >@@ -624,6 +656,8 @@ muxclient(const char *path, int ac, char **av) > buffer_put_int(&m, 0xffffffff); > else > buffer_put_int(&m, options.escape_char); >+ xasprintf(&tag, "%ld", (long)getpid()); >+ buffer_put_cstring(&m, tag); > buffer_append(&command, "\0", 1); > buffer_put_cstring(&m, buffer_ptr(&command)); > >diff --git a/ssh.c b/ssh.c >index d8f3f2e..0447c16 100644 >--- a/ssh.c >+++ b/ssh.c >@@ -305,6 +305,8 @@ main(int ac, char **av) > muxclient_command = SSHMUX_COMMAND_ALIVE_CHECK; > else if (strcmp(optarg, "exit") == 0) > muxclient_command = SSHMUX_COMMAND_TERMINATE; >+ else if (strcmp(optarg, "ps") == 0) >+ muxclient_command = SSHMUX_COMMAND_PS; > else > fatal("Invalid multiplex command."); > break;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1664
:
1706
|
1707
| 1708