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 4172bbc56..974d67f0b 100644
--- a/readpass.c
+++ b/readpass.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readpass.c,v 1.60 2019/12/06 03:06:08 djm Exp $ */ 1/* $OpenBSD: readpass.c,v 1.61 2020/01/23 07:10:22 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -65,10 +65,10 @@ ssh_askpass(char *askpass, const char *msg, const char *env_hint)
65 error("%s: pipe: %s", __func__, strerror(errno)); 65 error("%s: pipe: %s", __func__, strerror(errno));
66 return NULL; 66 return NULL;
67 } 67 }
68 osigchld = signal(SIGCHLD, SIG_DFL); 68 osigchld = ssh_signal(SIGCHLD, SIG_DFL);
69 if ((pid = fork()) == -1) { 69 if ((pid = fork()) == -1) {
70 error("%s: fork: %s", __func__, strerror(errno)); 70 error("%s: fork: %s", __func__, strerror(errno));
71 signal(SIGCHLD, osigchld); 71 ssh_signal(SIGCHLD, osigchld);
72 return NULL; 72 return NULL;
73 } 73 }
74 if (pid == 0) { 74 if (pid == 0) {
@@ -98,7 +98,7 @@ ssh_askpass(char *askpass, const char *msg, const char *env_hint)
98 while ((ret = waitpid(pid, &status, 0)) == -1) 98 while ((ret = waitpid(pid, &status, 0)) == -1)
99 if (errno != EINTR) 99 if (errno != EINTR)
100 break; 100 break;
101 signal(SIGCHLD, osigchld); 101 ssh_signal(SIGCHLD, osigchld);
102 if (ret == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) { 102 if (ret == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
103 explicit_bzero(buf, sizeof(buf)); 103 explicit_bzero(buf, sizeof(buf));
104 return NULL; 104 return NULL;
@@ -243,10 +243,10 @@ notify_start(int force_askpass, const char *fmt, ...)
243 free(prompt); 243 free(prompt);
244 return NULL; 244 return NULL;
245 } 245 }
246 osigchld = signal(SIGCHLD, SIG_DFL); 246 osigchld = ssh_signal(SIGCHLD, SIG_DFL);
247 if ((pid = fork()) == -1) { 247 if ((pid = fork()) == -1) {
248 error("%s: fork: %s", __func__, strerror(errno)); 248 error("%s: fork: %s", __func__, strerror(errno));
249 signal(SIGCHLD, osigchld); 249 ssh_signal(SIGCHLD, osigchld);
250 free(prompt); 250 free(prompt);
251 return NULL; 251 return NULL;
252 } 252 }
@@ -289,6 +289,6 @@ notify_complete(struct notifier_ctx *ctx)
289 } 289 }
290 if (ret == -1) 290 if (ret == -1)
291 fatal("%s: waitpid: %s", __func__, strerror(errno)); 291 fatal("%s: waitpid: %s", __func__, strerror(errno));
292 signal(SIGCHLD, ctx->osigchld); 292 ssh_signal(SIGCHLD, ctx->osigchld);
293 free(ctx); 293 free(ctx);
294} 294}