summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2016-06-03 03:14:41 +0000
committerDamien Miller <djm@mindrot.org>2016-06-08 11:39:31 +1000
commit8543ff3f5020fe659839b15f05b8c522bde6cee5 (patch)
treea8e83245849ea5102961bd386928f8ec287ebb82
parent6b87311d3acdc460f926b2c40f4c4f3fd345f368 (diff)
upstream commit
Move the host and port used by ssh -W into the Options struct. This will make future changes a bit easier. ok djm@ Upstream-ID: 151bce5ecab2fbedf0d836250a27968d30389382
-rw-r--r--mux.c10
-rw-r--r--readconf.c4
-rw-r--r--readconf.h6
-rw-r--r--ssh.c23
4 files changed, 22 insertions, 21 deletions
diff --git a/mux.c b/mux.c
index 6086f1ce1..98e3c0068 100644
--- a/mux.c
+++ b/mux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mux.c,v 1.59 2016/04/01 02:34:10 djm Exp $ */ 1/* $OpenBSD: mux.c,v 1.60 2016/06/03 03:14:41 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -88,8 +88,6 @@ extern char *host;
88extern int subsystem_flag; 88extern int subsystem_flag;
89extern Buffer command; 89extern Buffer command;
90extern volatile sig_atomic_t quit_pending; 90extern volatile sig_atomic_t quit_pending;
91extern char *stdio_forward_host;
92extern int stdio_forward_port;
93 91
94/* Context for session open confirmation callback */ 92/* Context for session open confirmation callback */
95struct mux_session_confirm_ctx { 93struct mux_session_confirm_ctx {
@@ -1991,8 +1989,8 @@ mux_client_request_stdio_fwd(int fd)
1991 buffer_put_int(&m, MUX_C_NEW_STDIO_FWD); 1989 buffer_put_int(&m, MUX_C_NEW_STDIO_FWD);
1992 buffer_put_int(&m, muxclient_request_id); 1990 buffer_put_int(&m, muxclient_request_id);
1993 buffer_put_cstring(&m, ""); /* reserved */ 1991 buffer_put_cstring(&m, ""); /* reserved */
1994 buffer_put_cstring(&m, stdio_forward_host); 1992 buffer_put_cstring(&m, options.stdio_forward_host);
1995 buffer_put_int(&m, stdio_forward_port); 1993 buffer_put_int(&m, options.stdio_forward_port);
1996 1994
1997 if (mux_client_write_packet(fd, &m) != 0) 1995 if (mux_client_write_packet(fd, &m) != 0)
1998 fatal("%s: write packet: %s", __func__, strerror(errno)); 1996 fatal("%s: write packet: %s", __func__, strerror(errno));
@@ -2116,7 +2114,7 @@ muxclient(const char *path)
2116 u_int pid; 2114 u_int pid;
2117 2115
2118 if (muxclient_command == 0) { 2116 if (muxclient_command == 0) {
2119 if (stdio_forward_host != NULL) 2117 if (options.stdio_forward_host != NULL)
2120 muxclient_command = SSHMUX_COMMAND_STDIO_FWD; 2118 muxclient_command = SSHMUX_COMMAND_STDIO_FWD;
2121 else 2119 else
2122 muxclient_command = SSHMUX_COMMAND_OPEN; 2120 muxclient_command = SSHMUX_COMMAND_OPEN;
diff --git a/readconf.c b/readconf.c
index c706fbf46..66a36a49f 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.254 2016/05/04 14:29:58 markus Exp $ */ 1/* $OpenBSD: readconf.c,v 1.255 2016/06/03 03:14:41 dtucker 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
@@ -1748,6 +1748,8 @@ initialize_options(Options * options)
1748 options->forward_x11 = -1; 1748 options->forward_x11 = -1;
1749 options->forward_x11_trusted = -1; 1749 options->forward_x11_trusted = -1;
1750 options->forward_x11_timeout = -1; 1750 options->forward_x11_timeout = -1;
1751 options->stdio_forward_host = NULL;
1752 options->stdio_forward_port = 0;
1751 options->exit_on_forward_failure = -1; 1753 options->exit_on_forward_failure = -1;
1752 options->xauth_location = NULL; 1754 options->xauth_location = NULL;
1753 options->fwd_opts.gateway_ports = -1; 1755 options->fwd_opts.gateway_ports = -1;
diff --git a/readconf.h b/readconf.h
index f0e498ea2..a8b0b9188 100644
--- a/readconf.h
+++ b/readconf.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.h,v 1.115 2016/05/04 12:21:53 markus Exp $ */ 1/* $OpenBSD: readconf.h,v 1.116 2016/06/03 03:14:41 dtucker Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -112,6 +112,10 @@ typedef struct {
112 struct Forward *remote_forwards; 112 struct Forward *remote_forwards;
113 int clear_forwardings; 113 int clear_forwardings;
114 114
115 /* stdio forwarding (-W) host and port */
116 char *stdio_forward_host;
117 int stdio_forward_port;
118
115 int enable_ssh_keysign; 119 int enable_ssh_keysign;
116 int64_t rekey_limit; 120 int64_t rekey_limit;
117 int rekey_interval; 121 int rekey_interval;
diff --git a/ssh.c b/ssh.c
index 7a536a0f7..702631c76 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.440 2016/05/04 14:29:58 markus Exp $ */ 1/* $OpenBSD: ssh.c,v 1.441 2016/06/03 03:14:41 dtucker 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
@@ -151,10 +151,6 @@ int ostdin_null_flag, ono_shell_flag, otty_flag, orequest_tty;
151 */ 151 */
152int fork_after_authentication_flag = 0; 152int fork_after_authentication_flag = 0;
153 153
154/* forward stdio to remote host and port */
155char *stdio_forward_host = NULL;
156int stdio_forward_port = 0;
157
158/* 154/*
159 * General data structure for command line options and options configurable 155 * General data structure for command line options and options configurable
160 * in configuration files. See readconf.h. 156 * in configuration files. See readconf.h.
@@ -651,7 +647,7 @@ main(int ac, char **av)
651 options.fwd_opts.gateway_ports = 1; 647 options.fwd_opts.gateway_ports = 1;
652 break; 648 break;
653 case 'O': 649 case 'O':
654 if (stdio_forward_host != NULL) 650 if (options.stdio_forward_host != NULL)
655 fatal("Cannot specify multiplexing " 651 fatal("Cannot specify multiplexing "
656 "command with -W"); 652 "command with -W");
657 else if (muxclient_command != 0) 653 else if (muxclient_command != 0)
@@ -770,13 +766,13 @@ main(int ac, char **av)
770 } 766 }
771 break; 767 break;
772 case 'W': 768 case 'W':
773 if (stdio_forward_host != NULL) 769 if (options.stdio_forward_host != NULL)
774 fatal("stdio forward already specified"); 770 fatal("stdio forward already specified");
775 if (muxclient_command != 0) 771 if (muxclient_command != 0)
776 fatal("Cannot specify stdio forward with -O"); 772 fatal("Cannot specify stdio forward with -O");
777 if (parse_forward(&fwd, optarg, 1, 0)) { 773 if (parse_forward(&fwd, optarg, 1, 0)) {
778 stdio_forward_host = fwd.listen_host; 774 options.stdio_forward_host = fwd.listen_host;
779 stdio_forward_port = fwd.listen_port; 775 options.stdio_forward_port = fwd.listen_port;
780 free(fwd.connect_host); 776 free(fwd.connect_host);
781 } else { 777 } else {
782 fprintf(stderr, 778 fprintf(stderr,
@@ -1538,18 +1534,19 @@ ssh_init_stdio_forwarding(void)
1538 Channel *c; 1534 Channel *c;
1539 int in, out; 1535 int in, out;
1540 1536
1541 if (stdio_forward_host == NULL) 1537 if (options.stdio_forward_host == NULL)
1542 return; 1538 return;
1543 if (!compat20) 1539 if (!compat20)
1544 fatal("stdio forwarding require Protocol 2"); 1540 fatal("stdio forwarding require Protocol 2");
1545 1541
1546 debug3("%s: %s:%d", __func__, stdio_forward_host, stdio_forward_port); 1542 debug3("%s: %s:%d", __func__, options.stdio_forward_host,
1543 options.stdio_forward_port);
1547 1544
1548 if ((in = dup(STDIN_FILENO)) < 0 || 1545 if ((in = dup(STDIN_FILENO)) < 0 ||
1549 (out = dup(STDOUT_FILENO)) < 0) 1546 (out = dup(STDOUT_FILENO)) < 0)
1550 fatal("channel_connect_stdio_fwd: dup() in/out failed"); 1547 fatal("channel_connect_stdio_fwd: dup() in/out failed");
1551 if ((c = channel_connect_stdio_fwd(stdio_forward_host, 1548 if ((c = channel_connect_stdio_fwd(options.stdio_forward_host,
1552 stdio_forward_port, in, out)) == NULL) 1549 options.stdio_forward_port, in, out)) == NULL)
1553 fatal("%s: channel_connect_stdio_fwd failed", __func__); 1550 fatal("%s: channel_connect_stdio_fwd failed", __func__);
1554 channel_register_cleanup(c->self, client_cleanup_stdio_fwd, 0); 1551 channel_register_cleanup(c->self, client_cleanup_stdio_fwd, 0);
1555 channel_register_open_confirm(c->self, ssh_stdio_confirm, NULL); 1552 channel_register_open_confirm(c->self, ssh_stdio_confirm, NULL);