summaryrefslogtreecommitdiff
path: root/sshconnect.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2020-01-23 07:10:22 +0000
committerDarren Tucker <dtucker@dtucker.net>2020-01-23 18:51:25 +1100
commit3bf2a6ac791d64046a537335a0f1d5e43579c5ad (patch)
tree76fcc0f1be306541c074be4aed3aca66023f0962 /sshconnect.c
parente027c044c796f3a01081a91bee55741204283f28 (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 'sshconnect.c')
-rw-r--r--sshconnect.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sshconnect.c b/sshconnect.c
index a2d759819..690240716 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect.c,v 1.326 2020/01/22 07:38:30 dtucker Exp $ */ 1/* $OpenBSD: sshconnect.c,v 1.327 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
@@ -259,7 +259,7 @@ ssh_proxy_connect(struct ssh *ssh, const char *host, const char *host_arg,
259 259
260 /* Execute the proxy command. Note that we gave up any 260 /* Execute the proxy command. Note that we gave up any
261 extra privileges above. */ 261 extra privileges above. */
262 signal(SIGPIPE, SIG_DFL); 262 ssh_signal(SIGPIPE, SIG_DFL);
263 execv(argv[0], argv); 263 execv(argv[0], argv);
264 perror(argv[0]); 264 perror(argv[0]);
265 exit(1); 265 exit(1);
@@ -1383,10 +1383,10 @@ ssh_local_cmd(const char *args)
1383 if ((shell = getenv("SHELL")) == NULL || *shell == '\0') 1383 if ((shell = getenv("SHELL")) == NULL || *shell == '\0')
1384 shell = _PATH_BSHELL; 1384 shell = _PATH_BSHELL;
1385 1385
1386 osighand = signal(SIGCHLD, SIG_DFL); 1386 osighand = ssh_signal(SIGCHLD, SIG_DFL);
1387 pid = fork(); 1387 pid = fork();
1388 if (pid == 0) { 1388 if (pid == 0) {
1389 signal(SIGPIPE, SIG_DFL); 1389 ssh_signal(SIGPIPE, SIG_DFL);
1390 debug3("Executing %s -c \"%s\"", shell, args); 1390 debug3("Executing %s -c \"%s\"", shell, args);
1391 execl(shell, shell, "-c", args, (char *)NULL); 1391 execl(shell, shell, "-c", args, (char *)NULL);
1392 error("Couldn't execute %s -c \"%s\": %s", 1392 error("Couldn't execute %s -c \"%s\": %s",
@@ -1397,7 +1397,7 @@ ssh_local_cmd(const char *args)
1397 while (waitpid(pid, &status, 0) == -1) 1397 while (waitpid(pid, &status, 0) == -1)
1398 if (errno != EINTR) 1398 if (errno != EINTR)
1399 fatal("Couldn't wait for child: %s", strerror(errno)); 1399 fatal("Couldn't wait for child: %s", strerror(errno));
1400 signal(SIGCHLD, osighand); 1400 ssh_signal(SIGCHLD, osighand);
1401 1401
1402 if (!WIFEXITED(status)) 1402 if (!WIFEXITED(status))
1403 return (1); 1403 return (1);