diff options
author | Damien Miller <djm@mindrot.org> | 2010-01-26 13:26:22 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2010-01-26 13:26:22 +1100 |
commit | e1537f951fa87e4d070adda82b474b25cf4902ec (patch) | |
tree | 3c9d794dcf7fca1d880ffd9db24b20038d3f800b /ssh.c | |
parent | f589fd1ea8c352e6bf819733ecd505119a694c51 (diff) |
- djm@cvs.openbsd.org 2010/01/26 01:28:35
[channels.c channels.h clientloop.c clientloop.h mux.c nchan.c ssh.c]
rewrite ssh(1) multiplexing code to a more sensible protocol.
The new multiplexing code uses channels for the listener and
accepted control sockets to make the mux master non-blocking, so
no stalls when processing messages from a slave.
avoid use of fatal() in mux master protocol parsing so an errant slave
process cannot take down a running master.
implement requesting of port-forwards over multiplexed sessions. Any
port forwards requested by the slave are added to those the master has
established.
add support for stdio forwarding ("ssh -W host:port ...") in mux slaves.
document master/slave mux protocol so that other tools can use it to
control a running ssh(1). Note: there are no guarantees that this
protocol won't be incompatibly changed (though it is versioned).
feedback Salvador Fandino, dtucker@
channel changes ok markus@
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.331 2010/01/11 01:39:46 dtucker Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.332 2010/01/26 01:28:35 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -319,6 +319,11 @@ main(int ac, char **av) | |||
319 | options.gateway_ports = 1; | 319 | options.gateway_ports = 1; |
320 | break; | 320 | break; |
321 | case 'O': | 321 | case 'O': |
322 | if (stdio_forward_host != NULL) | ||
323 | fatal("Cannot specify multiplexing " | ||
324 | "command with -W"); | ||
325 | else if (muxclient_command != 0) | ||
326 | fatal("Multiplexing command already specified"); | ||
322 | if (strcmp(optarg, "check") == 0) | 327 | if (strcmp(optarg, "check") == 0) |
323 | muxclient_command = SSHMUX_COMMAND_ALIVE_CHECK; | 328 | muxclient_command = SSHMUX_COMMAND_ALIVE_CHECK; |
324 | else if (strcmp(optarg, "exit") == 0) | 329 | else if (strcmp(optarg, "exit") == 0) |
@@ -395,6 +400,10 @@ main(int ac, char **av) | |||
395 | } | 400 | } |
396 | break; | 401 | break; |
397 | case 'W': | 402 | case 'W': |
403 | if (stdio_forward_host != NULL) | ||
404 | fatal("stdio forward already specified"); | ||
405 | if (muxclient_command != 0) | ||
406 | fatal("Cannot specify stdio forward with -O"); | ||
398 | if (parse_forward(&fwd, optarg, 1, 0)) { | 407 | if (parse_forward(&fwd, optarg, 1, 0)) { |
399 | stdio_forward_host = fwd.listen_host; | 408 | stdio_forward_host = fwd.listen_host; |
400 | stdio_forward_port = fwd.listen_port; | 409 | stdio_forward_port = fwd.listen_port; |
@@ -902,11 +911,18 @@ static int | |||
902 | client_setup_stdio_fwd(const char *host_to_connect, u_short port_to_connect) | 911 | client_setup_stdio_fwd(const char *host_to_connect, u_short port_to_connect) |
903 | { | 912 | { |
904 | Channel *c; | 913 | Channel *c; |
914 | int in, out; | ||
905 | 915 | ||
906 | debug3("client_setup_stdio_fwd %s:%d", host_to_connect, | 916 | debug3("client_setup_stdio_fwd %s:%d", host_to_connect, |
907 | port_to_connect); | 917 | port_to_connect); |
908 | if ((c = channel_connect_stdio_fwd(host_to_connect, port_to_connect)) | 918 | |
909 | == NULL) | 919 | in = dup(STDIN_FILENO); |
920 | out = dup(STDOUT_FILENO); | ||
921 | if (in < 0 || out < 0) | ||
922 | fatal("channel_connect_stdio_fwd: dup() in/out failed"); | ||
923 | |||
924 | if ((c = channel_connect_stdio_fwd(host_to_connect, port_to_connect, | ||
925 | in, out)) == NULL) | ||
910 | return 0; | 926 | return 0; |
911 | channel_register_cleanup(c->self, client_cleanup_stdio_fwd, 0); | 927 | channel_register_cleanup(c->self, client_cleanup_stdio_fwd, 0); |
912 | return 1; | 928 | return 1; |