Bugzilla – Attachment 1659 Details for
Bug 1618
Option to connect tty to a socket
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Implement stdio passthrough port forward mode
openssh-stdio-portforward3.patch (text/plain), 4.44 KB, created by
Darren Tucker
on 2009-07-02 21:57:30 AEST
(
hide
)
Description:
Implement stdio passthrough port forward mode
Filename:
MIME Type:
Creator:
Darren Tucker
Created:
2009-07-02 21:57:30 AEST
Size:
4.44 KB
patch
obsolete
>Index: channels.c >=================================================================== >RCS file: /home/dtucker/openssh/cvs/openssh/channels.c,v >retrieving revision 1.284 >diff -u -p -r1.284 channels.c >--- channels.c 21 Jun 2009 08:12:20 -0000 1.284 >+++ channels.c 2 Jul 2009 11:32:52 -0000 >@@ -1210,6 +1210,34 @@ channel_decode_socks5(Channel *c, fd_set > return 1; > } > >+Channel * >+channel_connect_stdio_fwd(const char *host_to_connect, u_short port_to_connect) >+{ >+ Channel *c; >+ int in, out; >+ >+ debug("channel_connect_stdio_fwd %s:%d", host_to_connect, port_to_connect); >+ >+ in = dup(STDIN_FILENO); >+ out = dup(STDOUT_FILENO); >+ if (in < 0 || out < 0) >+ fatal("channel_connect_stdio_fwd: dup() in/out failed"); >+ >+ c = channel_new("stdio-forward", SSH_CHANNEL_OPENING, in, out, >+ -1, CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, >+ 0, "stdio-forward", /*nonblock*/0); >+ >+ c->path = xstrdup(host_to_connect); >+ c->host_port = port_to_connect; >+ c->listening_port = 0; >+ c->force_drain = 1; >+ >+ channel_register_fds(c, in, out, -1, 0, 1, 0); >+ port_open_helper(c, "direct-tcpip"); >+ >+ return c; >+} >+ > /* dynamic port forwarding */ > static void > channel_pre_dynamic(Channel *c, fd_set *readset, fd_set *writeset) >Index: channels.h >=================================================================== >RCS file: /home/dtucker/openssh/cvs/openssh/channels.h,v >retrieving revision 1.91 >diff -u -p -r1.91 channels.h >--- channels.h 14 Feb 2009 05:28:21 -0000 1.91 >+++ channels.h 2 Jul 2009 11:32:20 -0000 >@@ -239,6 +239,7 @@ void channel_clear_adm_permitted_opens( > void channel_print_adm_permitted_opens(void); > int channel_input_port_forward_request(int, int); > Channel *channel_connect_to(const char *, u_short, char *, char *); >+Channel *channel_connect_stdio_fwd(const char*, u_short); > Channel *channel_connect_by_listen_address(u_short, char *, char *); > int channel_request_remote_forwarding(const char *, u_short, > const char *, u_short); >Index: ssh.c >=================================================================== >RCS file: /home/dtucker/openssh/cvs/openssh/ssh.c,v >retrieving revision 1.317 >diff -u -p -r1.317 ssh.c >--- ssh.c 21 Jun 2009 07:48:00 -0000 1.317 >+++ ssh.c 2 Jul 2009 11:50:09 -0000 >@@ -131,6 +131,9 @@ int stdin_null_flag = 0; > */ > int fork_after_authentication_flag = 0; > >+/* forward stdio to remote host */ >+int stdio_forward_mode = 0; >+ > /* > * General data structure for command line options and options configurable > * in configuration files. See readconf.h. >@@ -274,7 +277,7 @@ main(int ac, char **av) > > again: > while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx" >- "ACD:F:I:KL:MNO:PR:S:TVw:XYy")) != -1) { >+ "ACD:F:I:KL:MNO:PR:S:TVw:W:XYy")) != -1) { > switch (opt) { > case '1': > options.protocol = SSH_PROTO_1; >@@ -387,6 +390,22 @@ main(int ac, char **av) > exit(255); > } > break; >+ case 'W': >+ stdio_forward_mode = 1; >+ no_tty_flag = 1; >+ no_shell_flag = 1; >+ if (parse_forward(&fwd, optarg, 1, 0)) { >+ fwd.connect_host = fwd.listen_host; >+ fwd.connect_port = fwd.listen_port; >+ fwd.listen_port = 65535; >+ add_local_forward(&options, &fwd); >+ } else { >+ fprintf(stderr, >+ "Bad stdio forwarding specification '%s'\n", >+ optarg); >+ exit(255); >+ } >+ break; > case 'q': > options.log_level = SYSLOG_LEVEL_QUIET; > break; >@@ -868,11 +887,42 @@ ssh_confirm_remote_forward(int type, u_i > } > > static void >+client_cleanup_stdio_fwd(int id, void *arg) >+{ >+ debug("stdio forwarding: done"); >+ cleanup_exit(0); >+} >+ >+static int >+client_setup_stdio_fwd(const char *host_to_connect, u_short port_to_connect) >+{ >+ Channel *c; >+ >+ debug3("client_setup_stdio_fwd %s:%d", host_to_connect, port_to_connect); >+ options.exit_on_forward_failure = 1; >+ if ((c = channel_connect_stdio_fwd(host_to_connect, port_to_connect)) == NULL) >+ return 0; >+ channel_register_cleanup(c->self, client_cleanup_stdio_fwd, 0); >+ return 1; >+} >+ >+static void > ssh_init_forwarding(void) > { > int success = 0; > int i; > >+ if (stdio_forward_mode) { >+ if (options.num_local_forwards != 1) >+ fatal("Cannot specify additional forwardings in stdio " >+ "forward mode"); >+ if (!client_setup_stdio_fwd( >+ options.local_forwards[0].connect_host, >+ options.local_forwards[0].connect_port)) >+ fatal("Failed to connect in stdio forward mode."); >+ return; >+ } >+ > /* Initiate local TCP/IP port forwardings. */ > for (i = 0; i < options.num_local_forwards; i++) { > debug("Local connections to %.200s:%d forwarded to remote "
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 1618
:
1659
|
1660