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 /clientloop.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 'clientloop.c')
-rw-r--r-- | clientloop.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/clientloop.c b/clientloop.c index 4acf2806d..d4c23d554 100644 --- a/clientloop.c +++ b/clientloop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: clientloop.c,v 1.331 2020/01/23 02:46:49 dtucker Exp $ */ | 1 | /* $OpenBSD: clientloop.c,v 1.332 2020/01/23 07:10:22 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 |
@@ -785,7 +785,7 @@ process_cmdline(struct ssh *ssh) | |||
785 | memset(&fwd, 0, sizeof(fwd)); | 785 | memset(&fwd, 0, sizeof(fwd)); |
786 | 786 | ||
787 | leave_raw_mode(options.request_tty == REQUEST_TTY_FORCE); | 787 | leave_raw_mode(options.request_tty == REQUEST_TTY_FORCE); |
788 | handler = signal(SIGINT, SIG_IGN); | 788 | handler = ssh_signal(SIGINT, SIG_IGN); |
789 | cmd = s = read_passphrase("\r\nssh> ", RP_ECHO); | 789 | cmd = s = read_passphrase("\r\nssh> ", RP_ECHO); |
790 | if (s == NULL) | 790 | if (s == NULL) |
791 | goto out; | 791 | goto out; |
@@ -883,7 +883,7 @@ process_cmdline(struct ssh *ssh) | |||
883 | } | 883 | } |
884 | 884 | ||
885 | out: | 885 | out: |
886 | signal(SIGINT, handler); | 886 | ssh_signal(SIGINT, handler); |
887 | enter_raw_mode(options.request_tty == REQUEST_TTY_FORCE); | 887 | enter_raw_mode(options.request_tty == REQUEST_TTY_FORCE); |
888 | free(cmd); | 888 | free(cmd); |
889 | free(fwd.listen_host); | 889 | free(fwd.listen_host); |
@@ -1306,15 +1306,15 @@ client_loop(struct ssh *ssh, int have_pty, int escape_char_arg, | |||
1306 | * Set signal handlers, (e.g. to restore non-blocking mode) | 1306 | * Set signal handlers, (e.g. to restore non-blocking mode) |
1307 | * but don't overwrite SIG_IGN, matches behaviour from rsh(1) | 1307 | * but don't overwrite SIG_IGN, matches behaviour from rsh(1) |
1308 | */ | 1308 | */ |
1309 | if (signal(SIGHUP, SIG_IGN) != SIG_IGN) | 1309 | if (ssh_signal(SIGHUP, SIG_IGN) != SIG_IGN) |
1310 | signal(SIGHUP, signal_handler); | 1310 | ssh_signal(SIGHUP, signal_handler); |
1311 | if (signal(SIGINT, SIG_IGN) != SIG_IGN) | 1311 | if (ssh_signal(SIGINT, SIG_IGN) != SIG_IGN) |
1312 | signal(SIGINT, signal_handler); | 1312 | ssh_signal(SIGINT, signal_handler); |
1313 | if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) | 1313 | if (ssh_signal(SIGQUIT, SIG_IGN) != SIG_IGN) |
1314 | signal(SIGQUIT, signal_handler); | 1314 | ssh_signal(SIGQUIT, signal_handler); |
1315 | if (signal(SIGTERM, SIG_IGN) != SIG_IGN) | 1315 | if (ssh_signal(SIGTERM, SIG_IGN) != SIG_IGN) |
1316 | signal(SIGTERM, signal_handler); | 1316 | ssh_signal(SIGTERM, signal_handler); |
1317 | signal(SIGWINCH, window_change_handler); | 1317 | ssh_signal(SIGWINCH, window_change_handler); |
1318 | 1318 | ||
1319 | if (have_pty) | 1319 | if (have_pty) |
1320 | enter_raw_mode(options.request_tty == REQUEST_TTY_FORCE); | 1320 | enter_raw_mode(options.request_tty == REQUEST_TTY_FORCE); |
@@ -1413,7 +1413,7 @@ client_loop(struct ssh *ssh, int have_pty, int escape_char_arg, | |||
1413 | /* Terminate the session. */ | 1413 | /* Terminate the session. */ |
1414 | 1414 | ||
1415 | /* Stop watching for window change. */ | 1415 | /* Stop watching for window change. */ |
1416 | signal(SIGWINCH, SIG_DFL); | 1416 | ssh_signal(SIGWINCH, SIG_DFL); |
1417 | 1417 | ||
1418 | if ((r = sshpkt_start(ssh, SSH2_MSG_DISCONNECT)) != 0 || | 1418 | if ((r = sshpkt_start(ssh, SSH2_MSG_DISCONNECT)) != 0 || |
1419 | (r = sshpkt_put_u32(ssh, SSH2_DISCONNECT_BY_APPLICATION)) != 0 || | 1419 | (r = sshpkt_put_u32(ssh, SSH2_DISCONNECT_BY_APPLICATION)) != 0 || |