diff options
author | dtucker@openbsd.org <dtucker@openbsd.org> | 2020-01-23 07:10:22 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@dtucker.net> | 2020-01-23 18:51:25 +1100 |
commit | 3bf2a6ac791d64046a537335a0f1d5e43579c5ad (patch) | |
tree | 76fcc0f1be306541c074be4aed3aca66023f0962 /mux.c | |
parent | e027c044c796f3a01081a91bee55741204283f28 (diff) |
upstream: Replace all calls to signal(2) with a wrapper around
sigaction(2). This wrapper blocks all other signals during the handler
preventing races between handlers, and sets SA_RESTART which should reduce
the potential for short read/write operations.
OpenBSD-Commit-ID: 5e047663fd77a40d7b07bdabe68529df51fd2519
Diffstat (limited to 'mux.c')
-rw-r--r-- | mux.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: mux.c,v 1.80 2019/06/28 13:35:04 deraadt Exp $ */ | 1 | /* $OpenBSD: mux.c,v 1.81 2020/01/23 07:10:22 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 | * |
@@ -1911,7 +1911,7 @@ mux_client_request_session(int fd) | |||
1911 | return -1; | 1911 | return -1; |
1912 | } | 1912 | } |
1913 | 1913 | ||
1914 | signal(SIGPIPE, SIG_IGN); | 1914 | ssh_signal(SIGPIPE, SIG_IGN); |
1915 | 1915 | ||
1916 | if (stdin_null_flag) { | 1916 | if (stdin_null_flag) { |
1917 | if ((devnull = open(_PATH_DEVNULL, O_RDONLY)) == -1) | 1917 | if ((devnull = open(_PATH_DEVNULL, O_RDONLY)) == -1) |
@@ -2012,10 +2012,10 @@ mux_client_request_session(int fd) | |||
2012 | fatal("%s pledge(): %s", __func__, strerror(errno)); | 2012 | fatal("%s pledge(): %s", __func__, strerror(errno)); |
2013 | platform_pledge_mux(); | 2013 | platform_pledge_mux(); |
2014 | 2014 | ||
2015 | signal(SIGHUP, control_client_sighandler); | 2015 | ssh_signal(SIGHUP, control_client_sighandler); |
2016 | signal(SIGINT, control_client_sighandler); | 2016 | ssh_signal(SIGINT, control_client_sighandler); |
2017 | signal(SIGTERM, control_client_sighandler); | 2017 | ssh_signal(SIGTERM, control_client_sighandler); |
2018 | signal(SIGWINCH, control_client_sigrelay); | 2018 | ssh_signal(SIGWINCH, control_client_sigrelay); |
2019 | 2019 | ||
2020 | rawmode = tty_flag; | 2020 | rawmode = tty_flag; |
2021 | if (tty_flag) | 2021 | if (tty_flag) |
@@ -2145,7 +2145,7 @@ mux_client_request_stdio_fwd(int fd) | |||
2145 | return -1; | 2145 | return -1; |
2146 | } | 2146 | } |
2147 | 2147 | ||
2148 | signal(SIGPIPE, SIG_IGN); | 2148 | ssh_signal(SIGPIPE, SIG_IGN); |
2149 | 2149 | ||
2150 | if (stdin_null_flag) { | 2150 | if (stdin_null_flag) { |
2151 | if ((devnull = open(_PATH_DEVNULL, O_RDONLY)) == -1) | 2151 | if ((devnull = open(_PATH_DEVNULL, O_RDONLY)) == -1) |
@@ -2219,10 +2219,10 @@ mux_client_request_stdio_fwd(int fd) | |||
2219 | } | 2219 | } |
2220 | muxclient_request_id++; | 2220 | muxclient_request_id++; |
2221 | 2221 | ||
2222 | signal(SIGHUP, control_client_sighandler); | 2222 | ssh_signal(SIGHUP, control_client_sighandler); |
2223 | signal(SIGINT, control_client_sighandler); | 2223 | ssh_signal(SIGINT, control_client_sighandler); |
2224 | signal(SIGTERM, control_client_sighandler); | 2224 | ssh_signal(SIGTERM, control_client_sighandler); |
2225 | signal(SIGWINCH, control_client_sigrelay); | 2225 | ssh_signal(SIGWINCH, control_client_sigrelay); |
2226 | 2226 | ||
2227 | /* | 2227 | /* |
2228 | * Stick around until the controlee closes the client_fd. | 2228 | * Stick around until the controlee closes the client_fd. |