version 1.367, 2011/10/18 05:15:28 |
version 1.368, 2011/10/24 02:10:46 |
|
|
cleanup_exit(0); |
cleanup_exit(0); |
} |
} |
|
|
static int |
static void |
client_setup_stdio_fwd(const char *host_to_connect, u_short port_to_connect) |
ssh_init_stdio_forwarding(void) |
{ |
{ |
Channel *c; |
Channel *c; |
int in, out; |
int in, out; |
|
|
debug3("client_setup_stdio_fwd %s:%d", host_to_connect, |
if (stdio_forward_host == NULL) |
port_to_connect); |
return; |
|
if (!compat20) |
|
fatal("stdio forwarding require Protocol 2"); |
|
|
in = dup(STDIN_FILENO); |
debug3("%s: %s:%d", __func__, stdio_forward_host, stdio_forward_port); |
out = dup(STDOUT_FILENO); |
|
if (in < 0 || out < 0) |
|
fatal("channel_connect_stdio_fwd: dup() in/out failed"); |
|
|
|
if ((c = channel_connect_stdio_fwd(host_to_connect, port_to_connect, |
if ((in = dup(STDIN_FILENO)) < 0 || |
in, out)) == NULL) |
(out = dup(STDOUT_FILENO)) < 0) |
return 0; |
fatal("channel_connect_stdio_fwd: dup() in/out failed"); |
|
if ((c = channel_connect_stdio_fwd(stdio_forward_host, |
|
stdio_forward_port, in, out)) == NULL) |
|
fatal("%s: channel_connect_stdio_fwd failed", __func__); |
channel_register_cleanup(c->self, client_cleanup_stdio_fwd, 0); |
channel_register_cleanup(c->self, client_cleanup_stdio_fwd, 0); |
return 1; |
|
} |
} |
|
|
static void |
static void |
|
|
int success = 0; |
int success = 0; |
int i; |
int i; |
|
|
if (stdio_forward_host != NULL) { |
|
if (!compat20) { |
|
fatal("stdio forwarding require Protocol 2"); |
|
} |
|
if (!client_setup_stdio_fwd(stdio_forward_host, |
|
stdio_forward_port)) |
|
fatal("Failed to connect in stdio forward mode."); |
|
} |
|
|
|
/* Initiate local TCP/IP port forwardings. */ |
/* Initiate local TCP/IP port forwardings. */ |
for (i = 0; i < options.num_local_forwards; i++) { |
for (i = 0; i < options.num_local_forwards; i++) { |
debug("Local connections to %.200s:%d forwarded to remote " |
debug("Local connections to %.200s:%d forwarded to remote " |
|
|
} |
} |
|
|
/* Initiate port forwardings. */ |
/* Initiate port forwardings. */ |
|
ssh_init_stdio_forwarding(); |
ssh_init_forwarding(); |
ssh_init_forwarding(); |
|
|
/* Execute a local command */ |
/* Execute a local command */ |
|
|
int id = -1; |
int id = -1; |
|
|
/* XXX should be pre-session */ |
/* XXX should be pre-session */ |
|
if (!options.control_persist) |
|
ssh_init_stdio_forwarding(); |
ssh_init_forwarding(); |
ssh_init_forwarding(); |
|
|
/* Start listening for multiplex clients */ |
/* Start listening for multiplex clients */ |
muxserver_listen(); |
muxserver_listen(); |
|
|
/* |
/* |
* If we are in control persist mode, then prepare to background |
* If we are in control persist mode and have a working mux listen |
* ourselves and have a foreground client attach as a control |
* socket, then prepare to background ourselves and have a foreground |
* slave. NB. we must save copies of the flags that we override for |
* client attach as a control slave. |
|
* NB. we must save copies of the flags that we override for |
* the backgrounding, since we defer attachment of the slave until |
* the backgrounding, since we defer attachment of the slave until |
* after the connection is fully established (in particular, |
* after the connection is fully established (in particular, |
* async rfwd replies have been received for ExitOnForwardFailure). |
* async rfwd replies have been received for ExitOnForwardFailure). |
|
|
need_controlpersist_detach = 1; |
need_controlpersist_detach = 1; |
fork_after_authentication_flag = 1; |
fork_after_authentication_flag = 1; |
} |
} |
|
/* |
|
* ControlPersist mux listen socket setup failed, attempt the |
|
* stdio forward setup that we skipped earlier. |
|
*/ |
|
if (options.control_persist && muxserver_sock == -1) |
|
ssh_init_stdio_forwarding(); |
|
|
if (!no_shell_flag || (datafellows & SSH_BUG_DUMMYCHAN)) |
if (!no_shell_flag || (datafellows & SSH_BUG_DUMMYCHAN)) |
id = ssh_session2_open(); |
id = ssh_session2_open(); |