View | Details | Raw Unified | Return to bug 2416 | Differences between
and this patch

Collapse All | Expand All

(-)a/channels.c (-5 / +10 lines)
Lines 1269-1293 channel_decode_socks5(Channel *c, fd_set *readset, fd_set *writeset) Link Here
1269
}
1269
}
1270
1270
1271
Channel *
1271
Channel *
1272
channel_connect_stdio_fwd(const char *host_to_connect, u_short port_to_connect,
1272
channel_connect_stdio_fwd(const char *path_to_connect, u_int port_to_connect,
1273
    int in, int out)
1273
    int in, int out)
1274
{
1274
{
1275
	Channel *c;
1275
	Channel *c;
1276
1276
1277
	debug("channel_connect_stdio_fwd %s:%d", host_to_connect,
1277
	if (port_to_connect == (u_int)PORT_STREAMLOCAL)
1278
	    port_to_connect);
1278
		debug("channel_connect_stdio_fwd stream local %s", path_to_connect);
1279
	else
1280
		debug("channel_connect_stdio_fwd %s:%d", path_to_connect,
1281
		    port_to_connect);
1279
1282
1280
	c = channel_new("stdio-forward", SSH_CHANNEL_OPENING, in, out,
1283
	c = channel_new("stdio-forward", SSH_CHANNEL_OPENING, in, out,
1281
	    -1, CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
1284
	    -1, CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
1282
	    0, "stdio-forward", /*nonblock*/0);
1285
	    0, "stdio-forward", /*nonblock*/0);
1283
1286
1284
	c->path = xstrdup(host_to_connect);
1287
	c->path = xstrdup(path_to_connect);
1285
	c->host_port = port_to_connect;
1288
	c->host_port = port_to_connect;
1286
	c->listening_port = 0;
1289
	c->listening_port = 0;
1287
	c->force_drain = 1;
1290
	c->force_drain = 1;
1288
1291
1289
	channel_register_fds(c, in, out, -1, 0, 1, 0);
1292
	channel_register_fds(c, in, out, -1, 0, 1, 0);
1290
	port_open_helper(c, "direct-tcpip");
1293
	port_open_helper(c, ((port_to_connect == (u_int)PORT_STREAMLOCAL)
1294
			     ? "direct-streamlocal@openssh.com"
1295
			     : "direct-tcpip"));
1291
1296
1292
	return c;
1297
	return c;
1293
}
1298
}
(-)a/channels.h (-1 / +1 lines)
Lines 270-276 void channel_print_adm_permitted_opens(void); Link Here
270
int      channel_input_port_forward_request(int, struct ForwardOptions *);
270
int      channel_input_port_forward_request(int, struct ForwardOptions *);
271
Channel	*channel_connect_to_port(const char *, u_short, char *, char *);
271
Channel	*channel_connect_to_port(const char *, u_short, char *, char *);
272
Channel *channel_connect_to_path(const char *, char *, char *);
272
Channel *channel_connect_to_path(const char *, char *, char *);
273
Channel	*channel_connect_stdio_fwd(const char*, u_short, int, int);
273
Channel	*channel_connect_stdio_fwd(const char*, u_int, int, int);
274
Channel	*channel_connect_by_listen_address(const char *, u_short,
274
Channel	*channel_connect_by_listen_address(const char *, u_short,
275
	     char *, char *);
275
	     char *, char *);
276
Channel	*channel_connect_by_listen_path(const char *, char *, char *);
276
Channel	*channel_connect_by_listen_path(const char *, char *, char *);
(-)a/mux.c (-3 / +3 lines)
Lines 88-94 extern char *host; Link Here
88
extern int subsystem_flag;
88
extern int subsystem_flag;
89
extern Buffer command;
89
extern Buffer command;
90
extern volatile sig_atomic_t quit_pending;
90
extern volatile sig_atomic_t quit_pending;
91
extern char *stdio_forward_host;
91
extern char *stdio_forward_path;
92
extern int stdio_forward_port;
92
extern int stdio_forward_port;
93
93
94
/* Context for session open confirmation callback */
94
/* Context for session open confirmation callback */
Lines 1981-1987 mux_client_request_stdio_fwd(int fd) Link Here
1981
	buffer_put_int(&m, MUX_C_NEW_STDIO_FWD);
1981
	buffer_put_int(&m, MUX_C_NEW_STDIO_FWD);
1982
	buffer_put_int(&m, muxclient_request_id);
1982
	buffer_put_int(&m, muxclient_request_id);
1983
	buffer_put_cstring(&m, ""); /* reserved */
1983
	buffer_put_cstring(&m, ""); /* reserved */
1984
	buffer_put_cstring(&m, stdio_forward_host);
1984
	buffer_put_cstring(&m, stdio_forward_path);
1985
	buffer_put_int(&m, stdio_forward_port);
1985
	buffer_put_int(&m, stdio_forward_port);
1986
1986
1987
	if (mux_client_write_packet(fd, &m) != 0)
1987
	if (mux_client_write_packet(fd, &m) != 0)
Lines 2102-2108 muxclient(const char *path) Link Here
2102
	u_int pid;
2102
	u_int pid;
2103
2103
2104
	if (muxclient_command == 0) {
2104
	if (muxclient_command == 0) {
2105
		if (stdio_forward_host != NULL)
2105
		if (stdio_forward_path != NULL)
2106
			muxclient_command = SSHMUX_COMMAND_STDIO_FWD;
2106
			muxclient_command = SSHMUX_COMMAND_STDIO_FWD;
2107
		else
2107
		else
2108
			muxclient_command = SSHMUX_COMMAND_OPEN;
2108
			muxclient_command = SSHMUX_COMMAND_OPEN;
(-)a/ssh.c (-9 / +13 lines)
Lines 151-158 int ostdin_null_flag, ono_shell_flag, otty_flag, orequest_tty; Link Here
151
 */
151
 */
152
int fork_after_authentication_flag = 0;
152
int fork_after_authentication_flag = 0;
153
153
154
/* forward stdio to remote host and port */
154
/* forward stdio to remote host and port or unix socket */
155
char *stdio_forward_host = NULL;
155
char *stdio_forward_path = NULL;
156
int stdio_forward_port = 0;
156
int stdio_forward_port = 0;
157
157
158
/*
158
/*
Lines 639-645 main(int ac, char **av) Link Here
639
			options.fwd_opts.gateway_ports = 1;
639
			options.fwd_opts.gateway_ports = 1;
640
			break;
640
			break;
641
		case 'O':
641
		case 'O':
642
			if (stdio_forward_host != NULL)
642
			if (stdio_forward_path != NULL)
643
				fatal("Cannot specify multiplexing "
643
				fatal("Cannot specify multiplexing "
644
				    "command with -W");
644
				    "command with -W");
645
			else if (muxclient_command != 0)
645
			else if (muxclient_command != 0)
Lines 756-767 main(int ac, char **av) Link Here
756
			}
756
			}
757
			break;
757
			break;
758
		case 'W':
758
		case 'W':
759
			if (stdio_forward_host != NULL)
759
			if (stdio_forward_path != NULL)
760
				fatal("stdio forward already specified");
760
				fatal("stdio forward already specified");
761
			if (muxclient_command != 0)
761
			if (muxclient_command != 0)
762
				fatal("Cannot specify stdio forward with -O");
762
				fatal("Cannot specify stdio forward with -O");
763
			if (parse_forward(&fwd, optarg, 1, 0)) {
763
			if (parse_forward(&fwd, optarg, 1, 0)) {
764
				stdio_forward_host = fwd.listen_host;
764
				stdio_forward_path = ((fwd.listen_port == PORT_STREAMLOCAL)
765
						      ? fwd.listen_path
766
						      : fwd.listen_host);
765
				stdio_forward_port = fwd.listen_port;
767
				stdio_forward_port = fwd.listen_port;
766
				free(fwd.connect_host);
768
				free(fwd.connect_host);
767
			} else {
769
			} else {
Lines 1493-1509 ssh_init_stdio_forwarding(void) Link Here
1493
	Channel *c;
1495
	Channel *c;
1494
	int in, out;
1496
	int in, out;
1495
1497
1496
	if (stdio_forward_host == NULL)
1498
	if (stdio_forward_path == NULL)
1497
		return;
1499
		return;
1498
	if (!compat20)
1500
	if (!compat20)
1499
		fatal("stdio forwarding require Protocol 2");
1501
		fatal("stdio forwarding require Protocol 2");
1500
1502
1501
	debug3("%s: %s:%d", __func__, stdio_forward_host, stdio_forward_port);
1503
	if (stdio_forward_port == PORT_STREAMLOCAL)
1504
		debug3("%s: stream local %s", __func__, stdio_forward_path);
1505
	else
1506
		debug3("%s: %s:%d", __func__, stdio_forward_path, stdio_forward_port);
1502
1507
1503
	if ((in = dup(STDIN_FILENO)) < 0 ||
1508
	if ((in = dup(STDIN_FILENO)) < 0 ||
1504
	    (out = dup(STDOUT_FILENO)) < 0)
1509
	    (out = dup(STDOUT_FILENO)) < 0)
1505
		fatal("channel_connect_stdio_fwd: dup() in/out failed");
1510
		fatal("channel_connect_stdio_fwd: dup() in/out failed");
1506
	if ((c = channel_connect_stdio_fwd(stdio_forward_host,
1511
	if ((c = channel_connect_stdio_fwd(stdio_forward_path,
1507
	    stdio_forward_port, in, out)) == NULL)
1512
	    stdio_forward_port, in, out)) == NULL)
1508
		fatal("%s: channel_connect_stdio_fwd failed", __func__);
1513
		fatal("%s: channel_connect_stdio_fwd failed", __func__);
1509
	channel_register_cleanup(c->self, client_cleanup_stdio_fwd, 0);
1514
	channel_register_cleanup(c->self, client_cleanup_stdio_fwd, 0);
1510
- 

Return to bug 2416