summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/sshconnect.c
diff options
context:
space:
mode:
authormarkus <markus@openbsd.org>2019-02-27 19:37:01 +0000
committermarkus <markus@openbsd.org>2019-02-27 19:37:01 +0000
commitf185261edac99ddef32ea05128e56069af0bc7ac (patch)
treedaa0b74f57f60131d9229dd62c99a319197ac991 /usr.bin/ssh/sshconnect.c
parentMake iwm(4) use CTS-to-self for HT protection if the AP requests this, (diff)
downloadwireguard-openbsd-f185261edac99ddef32ea05128e56069af0bc7ac.tar.xz
wireguard-openbsd-f185261edac99ddef32ea05128e56069af0bc7ac.zip
dup stdout/in for proxycommand=-, otherwise stdout might be
redirected to /dev/null; ok djm@
Diffstat (limited to 'usr.bin/ssh/sshconnect.c')
-rw-r--r--usr.bin/ssh/sshconnect.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c
index 585375d5c6e..4326c697ef3 100644
--- a/usr.bin/ssh/sshconnect.c
+++ b/usr.bin/ssh/sshconnect.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshconnect.c,v 1.313 2019/02/01 03:52:23 dtucker Exp $ */
+/* $OpenBSD: sshconnect.c,v 1.314 2019/02/27 19:37:01 markus Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -523,12 +523,20 @@ ssh_connect(struct ssh *ssh, const char *host, struct addrinfo *addrs,
struct sockaddr_storage *hostaddr, u_short port, int family,
int connection_attempts, int *timeout_ms, int want_keepalive)
{
+ int in, out;
+
if (options.proxy_command == NULL) {
return ssh_connect_direct(ssh, host, addrs, hostaddr, port,
family, connection_attempts, timeout_ms, want_keepalive);
} else if (strcmp(options.proxy_command, "-") == 0) {
- if ((ssh_packet_set_connection(ssh,
- STDIN_FILENO, STDOUT_FILENO)) == NULL)
+ if ((in = dup(STDIN_FILENO)) < 0 ||
+ (out = dup(STDOUT_FILENO)) < 0) {
+ if (in >= 0)
+ close(in);
+ error("%s: dup() in/out failed", __func__);
+ return -1; /* ssh_packet_set_connection logs error */
+ }
+ if ((ssh_packet_set_connection(ssh, in, out)) == NULL)
return -1; /* ssh_packet_set_connection logs error */
return 0;
} else if (options.proxy_use_fdpass) {