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 / +46 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 and port */
135
char *stdio_forward_host = NULL;
136
int stdio_forward_port = 0;
137
134
/*
138
/*
135
 * General data structure for command line options and options configurable
139
 * General data structure for command line options and options configurable
136
 * in configuration files.  See readconf.h.
140
 * in configuration files.  See readconf.h.
Lines 274-280 main(int ac, char **av) Link Here
274
278
275
 again:
279
 again:
276
	while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx"
280
	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) {
281
	    "ACD:F:I:KL:MNO:PR:S:TVw:W:XYy")) != -1) {
278
		switch (opt) {
282
		switch (opt) {
279
		case '1':
283
		case '1':
280
			options.protocol = SSH_PROTO_1;
284
			options.protocol = SSH_PROTO_1;
Lines 387-392 main(int ac, char **av) Link Here
387
				exit(255);
391
				exit(255);
388
			}
392
			}
389
			break;
393
			break;
394
		case 'W':
395
			if (parse_forward(&fwd, optarg, 1, 0)) {
396
				stdio_forward_host = fwd.listen_host;
397
				stdio_forward_port = fwd.listen_port;
398
				xfree(fwd.connect_host);
399
			} else {
400
				fprintf(stderr,
401
				    "Bad stdio forwarding specification '%s'\n",
402
				    optarg);
403
				exit(255);
404
			}
405
			no_tty_flag = 1;
406
			no_shell_flag = 1;
407
			options.clear_forwardings = 1;
408
			options.exit_on_forward_failure = 1;
409
			break;
390
		case 'q':
410
		case 'q':
391
			options.log_level = SYSLOG_LEVEL_QUIET;
411
			options.log_level = SYSLOG_LEVEL_QUIET;
392
			break;
412
			break;
Lines 868-878 ssh_confirm_remote_forward(int type, u_i Link Here
868
}
888
}
869
889
870
static void
890
static void
891
client_cleanup_stdio_fwd(int id, void *arg)
892
{
893
	debug("stdio forwarding: done");
894
	cleanup_exit(0);
895
}
896
897
static int
898
client_setup_stdio_fwd(const char *host_to_connect, u_short port_to_connect)
899
{
900
	Channel *c;
901
902
	debug3("client_setup_stdio_fwd %s:%d", host_to_connect, port_to_connect);
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_host != NULL) {
916
		if (!client_setup_stdio_fwd(stdio_forward_host,
917
		    stdio_forward_port))
918
			fatal("Failed to connect in stdio forward mode.");
919
	}
920
876
	/* Initiate local TCP/IP port forwardings. */
921
	/* Initiate local TCP/IP port forwardings. */
877
	for (i = 0; i < options.num_local_forwards; i++) {
922
	for (i = 0; i < options.num_local_forwards; i++) {
878
		debug("Local connections to %.200s:%d forwarded to remote "
923
		debug("Local connections to %.200s:%d forwarded to remote "

Return to bug 1618