summaryrefslogtreecommitdiff
path: root/readpass.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 /readpass.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 'readpass.c')
-rw-r--r--readpass.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/readpass.c b/readpass.c
index 4172bbc5..974d67f0 100644
--- a/readpass.c
+++ b/readpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readpass.c,v 1.60 2019/12/06 03:06:08 djm Exp $ */
+/* $OpenBSD: readpass.c,v 1.61 2020/01/23 07:10:22 dtucker Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
*
@@ -65,10 +65,10 @@ ssh_askpass(char *askpass, const char *msg, const char *env_hint)
error("%s: pipe: %s", __func__, strerror(errno));
return NULL;
}
- osigchld = signal(SIGCHLD, SIG_DFL);
+ osigchld = ssh_signal(SIGCHLD, SIG_DFL);
if ((pid = fork()) == -1) {
error("%s: fork: %s", __func__, strerror(errno));
- signal(SIGCHLD, osigchld);
+ ssh_signal(SIGCHLD, osigchld);
return NULL;
}
if (pid == 0) {
@@ -98,7 +98,7 @@ ssh_askpass(char *askpass, const char *msg, const char *env_hint)
while ((ret = waitpid(pid, &status, 0)) == -1)
if (errno != EINTR)
break;
- signal(SIGCHLD, osigchld);
+ ssh_signal(SIGCHLD, osigchld);
if (ret == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
explicit_bzero(buf, sizeof(buf));
return NULL;
@@ -243,10 +243,10 @@ notify_start(int force_askpass, const char *fmt, ...)
free(prompt);
return NULL;
}
- osigchld = signal(SIGCHLD, SIG_DFL);
+ osigchld = ssh_signal(SIGCHLD, SIG_DFL);
if ((pid = fork()) == -1) {
error("%s: fork: %s", __func__, strerror(errno));
- signal(SIGCHLD, osigchld);
+ ssh_signal(SIGCHLD, osigchld);
free(prompt);
return NULL;
}
@@ -289,6 +289,6 @@ notify_complete(struct notifier_ctx *ctx)
}
if (ret == -1)
fatal("%s: waitpid: %s", __func__, strerror(errno));
- signal(SIGCHLD, ctx->osigchld);
+ ssh_signal(SIGCHLD, ctx->osigchld);
free(ctx);
}