diff options
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.466 2017/10/23 05:08:00 djm Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.467 2017/10/25 00:21:37 djm 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 |
@@ -1817,7 +1817,7 @@ ssh_session2_open(struct ssh *ssh) | |||
1817 | static int | 1817 | static int |
1818 | ssh_session2(struct ssh *ssh, struct passwd *pw) | 1818 | ssh_session2(struct ssh *ssh, struct passwd *pw) |
1819 | { | 1819 | { |
1820 | int id = -1; | 1820 | int devnull, id = -1; |
1821 | char *cp, *tun_fwd_ifname = NULL; | 1821 | char *cp, *tun_fwd_ifname = NULL; |
1822 | 1822 | ||
1823 | /* XXX should be pre-session */ | 1823 | /* XXX should be pre-session */ |
@@ -1901,6 +1901,20 @@ ssh_session2(struct ssh *ssh, struct passwd *pw) | |||
1901 | ssh_local_cmd(options.local_command); | 1901 | ssh_local_cmd(options.local_command); |
1902 | 1902 | ||
1903 | /* | 1903 | /* |
1904 | * stdout is now owned by the session channel; clobber it here | ||
1905 | * so future channel closes are propagated to the local fd. | ||
1906 | * NB. this can only happen after LocalCommand has completed, | ||
1907 | * as it may want to write to stdout. | ||
1908 | */ | ||
1909 | if ((devnull = open(_PATH_DEVNULL, O_WRONLY)) == -1) | ||
1910 | error("%s: open %s: %s", __func__, | ||
1911 | _PATH_DEVNULL, strerror(errno)); | ||
1912 | if (dup2(devnull, STDOUT_FILENO) < 0) | ||
1913 | fatal("%s: dup2() stdout failed", __func__); | ||
1914 | if (devnull > STDERR_FILENO) | ||
1915 | close(devnull); | ||
1916 | |||
1917 | /* | ||
1904 | * If requested and we are not interested in replies to remote | 1918 | * If requested and we are not interested in replies to remote |
1905 | * forwarding requests, then let ssh continue in the background. | 1919 | * forwarding requests, then let ssh continue in the background. |
1906 | */ | 1920 | */ |