Bugzilla – Attachment 1310 Details for
Bug 1232
"LocalCommand" is executed before session is set up
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Request tunnel earlier
tun-req-delay.diff (text/plain), 4.40 KB, created by
Damien Miller
on 2007-06-22 15:18:01 AEST
(
hide
)
Description:
Request tunnel earlier
Filename:
MIME Type:
Creator:
Damien Miller
Created:
2007-06-22 15:18:01 AEST
Size:
4.40 KB
patch
obsolete
>Index: ssh.c >=================================================================== >RCS file: /var/cvs/openssh/ssh.c,v >retrieving revision 1.289 >diff -u -p -r1.289 ssh.c >--- ssh.c 12 Jun 2007 13:44:10 -0000 1.289 >+++ ssh.c 22 Jun 2007 05:14:41 -0000 >@@ -857,6 +857,17 @@ ssh_init_forwarding(void) > "forwarding."); > } > } >+ >+ /* Initiate tunnel forwarding. */ >+ if (options.tun_open != SSH_TUNMODE_NO) { >+ if (client_request_tun_fwd(options.tun_open, >+ options.tun_local, options.tun_remote) < 0) { >+ if (options.exit_on_forward_failure) >+ fatal("Could not request tunnel forwarding."); >+ else >+ error("Could not request tunnel forwarding."); >+ } >+ } > } > > static void >@@ -1119,33 +1130,6 @@ ssh_session2_setup(int id, void *arg) > packet_send(); > } > >- if (options.tun_open != SSH_TUNMODE_NO) { >- Channel *c; >- int fd; >- >- debug("Requesting tun."); >- if ((fd = tun_open(options.tun_local, >- options.tun_open)) >= 0) { >- c = channel_new("tun", SSH_CHANNEL_OPENING, fd, fd, -1, >- CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, >- 0, "tun", 1); >- c->datagram = 1; >-#if defined(SSH_TUN_FILTER) >- if (options.tun_open == SSH_TUNMODE_POINTOPOINT) >- channel_register_filter(c->self, sys_tun_infilter, >- sys_tun_outfilter); >-#endif >- packet_start(SSH2_MSG_CHANNEL_OPEN); >- packet_put_cstring("tun@openssh.com"); >- packet_put_int(c->self); >- packet_put_int(c->local_window_max); >- packet_put_int(c->local_maxpacket); >- packet_put_int(options.tun_open); >- packet_put_int(options.tun_remote); >- packet_send(); >- } >- } >- > client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"), > NULL, fileno(stdin), &command, environ, &ssh_subsystem_reply); > >@@ -1205,7 +1189,6 @@ ssh_session2(void) > > /* XXX should be pre-session */ > ssh_init_forwarding(); >- ssh_control_listener(); > > if (!no_shell_flag || (datafellows & SSH_BUG_DUMMYCHAN)) > id = ssh_session2_open(); >@@ -1214,6 +1197,9 @@ ssh_session2(void) > if (options.local_command != NULL && > options.permit_local_command) > ssh_local_cmd(options.local_command); >+ >+ /* Start listening for multiplex clients */ >+ ssh_control_listener(); > > /* If requested, let ssh continue in the background. */ > if (fork_after_authentication_flag) >Index: clientloop.c >=================================================================== >RCS file: /var/cvs/openssh/clientloop.c,v >retrieving revision 1.165 >diff -u -p -r1.165 clientloop.c >--- clientloop.c 21 Mar 2007 09:46:03 -0000 1.165 >+++ clientloop.c 22 Jun 2007 05:14:41 -0000 >@@ -1773,6 +1773,51 @@ client_request_agent(const char *request > return c; > } > >+int >+client_request_tun_fwd(int tun_mode, int local_tun, int remote_tun) >+{ >+ Channel *c; >+ int fd; >+ >+ if (tun_mode == SSH_TUNMODE_NO) >+ return 0; >+ >+ if (!compat20) { >+ error("Tunnel forwarding is not support for protocol 1"); >+ return -1; >+ } >+ >+ debug("Requesting tun unit %d in mode %d", local_tun, tun_mode); >+ >+ /* Open local tunnel device */ >+ if ((fd = tun_open(local_tun, tun_mode)) == -1) { >+ error("Tunnel device open failed."); >+ return -1; >+ } >+ >+ c = channel_new("tun", SSH_CHANNEL_OPENING, fd, fd, -1, >+ CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 0, "tun", 1); >+ c->datagram = 1; >+ >+#if defined(SSH_TUN_FILTER) >+ if (options.tun_open == SSH_TUNMODE_POINTOPOINT) >+ channel_register_filter(c->self, sys_tun_infilter, >+ sys_tun_outfilter); >+#endif >+ >+ packet_start(SSH2_MSG_CHANNEL_OPEN); >+ packet_put_cstring("tun@openssh.com"); >+ packet_put_int(c->self); >+ packet_put_int(c->local_window_max); >+ packet_put_int(c->local_maxpacket); >+ packet_put_int(tun_mode); >+ packet_put_int(remote_tun); >+ packet_send(); >+ >+ /* Assume that server accepts the request */ >+ return 0; >+} >+ > /* XXXX move to generic input handler */ > static void > client_input_channel_open(int type, u_int32_t seq, void *ctxt) >Index: clientloop.h >=================================================================== >RCS file: /var/cvs/openssh/clientloop.h,v >retrieving revision 1.16 >diff -u -p -r1.16 clientloop.h >--- clientloop.h 26 Mar 2006 03:30:01 -0000 1.16 >+++ clientloop.h 22 Jun 2007 05:14:41 -0000 >@@ -44,6 +44,7 @@ void client_x11_get_proto(const char *, > void client_global_request_reply_fwd(int, u_int32_t, void *); > void client_session2_setup(int, int, int, const char *, struct termios *, > int, Buffer *, char **, dispatch_fn *); >+int client_request_tun_fwd(int, int, int); > > /* Multiplexing protocol version */ > #define SSHMUX_VER 1
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 1232
: 1310