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

Collapse All | Expand All

(-)channels.c (+28 lines)
Lines 1210-1215 channel_decode_socks5(Channel *c, fd_set Link Here
1210
	return 1;
1210
	return 1;
1211
}
1211
}
1212
1212
1213
Channel *
1214
channel_connect_stdio_fwd(const char *host_to_connect, u_short port_to_connect)
1215
{
1216
	Channel *c;
1217
	int in, out;
1218
1219
	debug("channel_connect_stdio_fwd %s:%d", host_to_connect, port_to_connect);
1220
1221
	in = dup(STDIN_FILENO);
1222
	out = dup(STDOUT_FILENO);
1223
	if (in < 0 || out < 0)
1224
		fatal("channel_connect_stdio_fwd: dup() in/out failed");
1225
1226
	c = channel_new("stdio-forward", SSH_CHANNEL_OPENING, in, out,
1227
	    -1, CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
1228
	    0, "stdio-forward", /*nonblock*/0);
1229
1230
	c->path = xstrdup(host_to_connect);
1231
	c->host_port = port_to_connect;
1232
	c->listening_port = 0;
1233
	c->force_drain = 1;
1234
1235
	channel_register_fds(c, in, out, -1, 0, 1, 0);
1236
	port_open_helper(c, "direct-tcpip");
1237
1238
	return c;
1239
}
1240
1213
/* dynamic port forwarding */
1241
/* dynamic port forwarding */
1214
static void
1242
static void
1215
channel_pre_dynamic(Channel *c, fd_set *readset, fd_set *writeset)
1243
channel_pre_dynamic(Channel *c, fd_set *readset, fd_set *writeset)
(-)channels.h (+1 lines)
Lines 239-244 void channel_clear_adm_permitted_opens( Link Here
239
void 	 channel_print_adm_permitted_opens(void);
239
void 	 channel_print_adm_permitted_opens(void);
240
int      channel_input_port_forward_request(int, int);
240
int      channel_input_port_forward_request(int, int);
241
Channel	*channel_connect_to(const char *, u_short, char *, char *);
241
Channel	*channel_connect_to(const char *, u_short, char *, char *);
242
Channel	*channel_connect_stdio_fwd(const char*, u_short);
242
Channel	*channel_connect_by_listen_address(u_short, char *, char *);
243
Channel	*channel_connect_by_listen_address(u_short, char *, char *);
243
int	 channel_request_remote_forwarding(const char *, u_short,
244
int	 channel_request_remote_forwarding(const char *, u_short,
244
	     const char *, u_short);
245
	     const char *, u_short);
(-)ssh.c (-1 / +51 lines)
Lines 131-136 int stdin_null_flag = 0; Link Here
131
 */
131
 */
132
int fork_after_authentication_flag = 0;
132
int fork_after_authentication_flag = 0;
133
133
134
/* forward stdio to remote host */
135
int stdio_forward_mode = 0;
136
134
/*
137
/*
135
 * General data structure for command line options and options configurable
138
 * General data structure for command line options and options configurable
136
 * in configuration files.  See readconf.h.
139
 * in configuration files.  See readconf.h.
Lines 274-280 main(int ac, char **av) Link Here
274
277
275
 again:
278
 again:
276
	while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx"
279
	while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx"
277
	    "ACD:F:I:KL:MNO:PR:S:TVw:XYy")) != -1) {
280
	    "ACD:F:I:KL:MNO:PR:S:TVw:W:XYy")) != -1) {
278
		switch (opt) {
281
		switch (opt) {
279
		case '1':
282
		case '1':
280
			options.protocol = SSH_PROTO_1;
283
			options.protocol = SSH_PROTO_1;
Lines 387-392 main(int ac, char **av) Link Here
387
				exit(255);
390
				exit(255);
388
			}
391
			}
389
			break;
392
			break;
393
		case 'W':
394
			stdio_forward_mode = 1;
395
			no_tty_flag = 1;
396
			no_shell_flag = 1;
397
			if (parse_forward(&fwd, optarg, 1, 0)) {
398
				fwd.connect_host = fwd.listen_host;
399
				fwd.connect_port = fwd.listen_port;
400
				fwd.listen_port = 65535;
401
				add_local_forward(&options, &fwd);
402
			} else {
403
				fprintf(stderr,
404
				    "Bad stdio forwarding specification '%s'\n",
405
				    optarg);
406
				exit(255);
407
			}
408
			break;
390
		case 'q':
409
		case 'q':
391
			options.log_level = SYSLOG_LEVEL_QUIET;
410
			options.log_level = SYSLOG_LEVEL_QUIET;
392
			break;
411
			break;
Lines 868-878 ssh_confirm_remote_forward(int type, u_i Link Here
868
}
887
}
869
888
870
static void
889
static void
890
client_cleanup_stdio_fwd(int id, void *arg)
891
{
892
	debug("stdio forwarding: done");
893
	cleanup_exit(0);
894
}
895
896
static int
897
client_setup_stdio_fwd(const char *host_to_connect, u_short port_to_connect)
898
{
899
	Channel *c;
900
901
	debug3("client_setup_stdio_fwd %s:%d", host_to_connect, port_to_connect);
902
	options.exit_on_forward_failure = 1;
903
	if ((c = channel_connect_stdio_fwd(host_to_connect, port_to_connect)) == NULL)
904
		return 0;
905
	channel_register_cleanup(c->self, client_cleanup_stdio_fwd, 0);
906
	return 1;
907
}
908
909
static void
871
ssh_init_forwarding(void)
910
ssh_init_forwarding(void)
872
{
911
{
873
	int success = 0;
912
	int success = 0;
874
	int i;
913
	int i;
875
914
915
	if (stdio_forward_mode) {
916
		if (options.num_local_forwards != 1)
917
			fatal("Cannot specify additional forwardings in stdio "
918
			   "forward mode");
919
		if (!client_setup_stdio_fwd(
920
		    options.local_forwards[0].connect_host,
921
		    options.local_forwards[0].connect_port))
922
			fatal("Failed to connect in stdio forward mode.");
923
		return;
924
	}
925
876
	/* Initiate local TCP/IP port forwardings. */
926
	/* Initiate local TCP/IP port forwardings. */
877
	for (i = 0; i < options.num_local_forwards; i++) {
927
	for (i = 0; i < options.num_local_forwards; i++) {
878
		debug("Local connections to %.200s:%d forwarded to remote "
928
		debug("Local connections to %.200s:%d forwarded to remote "

Return to bug 1618