summaryrefslogtreecommitdiff
path: root/auth-pam.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 /auth-pam.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 'auth-pam.c')
-rw-r--r--auth-pam.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/auth-pam.c b/auth-pam.c
index 856fdd40f..0cd2b0019 100644
--- a/auth-pam.c
+++ b/auth-pam.c
@@ -156,7 +156,7 @@ static mysig_t sshpam_oldsig;
156static void 156static void
157sshpam_sigchld_handler(int sig) 157sshpam_sigchld_handler(int sig)
158{ 158{
159 signal(SIGCHLD, SIG_DFL); 159 ssh_signal(SIGCHLD, SIG_DFL);
160 if (cleanup_ctxt == NULL) 160 if (cleanup_ctxt == NULL)
161 return; /* handler called after PAM cleanup, shouldn't happen */ 161 return; /* handler called after PAM cleanup, shouldn't happen */
162 if (waitpid(cleanup_ctxt->pam_thread, &sshpam_thread_status, WNOHANG) 162 if (waitpid(cleanup_ctxt->pam_thread, &sshpam_thread_status, WNOHANG)
@@ -208,7 +208,7 @@ pthread_create(sp_pthread_t *thread, const void *attr,
208 *thread = pid; 208 *thread = pid;
209 close(ctx->pam_csock); 209 close(ctx->pam_csock);
210 ctx->pam_csock = -1; 210 ctx->pam_csock = -1;
211 sshpam_oldsig = signal(SIGCHLD, sshpam_sigchld_handler); 211 sshpam_oldsig = ssh_signal(SIGCHLD, sshpam_sigchld_handler);
212 return (0); 212 return (0);
213 } 213 }
214} 214}
@@ -216,7 +216,7 @@ pthread_create(sp_pthread_t *thread, const void *attr,
216static int 216static int
217pthread_cancel(sp_pthread_t thread) 217pthread_cancel(sp_pthread_t thread)
218{ 218{
219 signal(SIGCHLD, sshpam_oldsig); 219 ssh_signal(SIGCHLD, sshpam_oldsig);
220 return (kill(thread, SIGTERM)); 220 return (kill(thread, SIGTERM));
221} 221}
222 222
@@ -228,7 +228,7 @@ pthread_join(sp_pthread_t thread, void **value)
228 228
229 if (sshpam_thread_status != -1) 229 if (sshpam_thread_status != -1)
230 return (sshpam_thread_status); 230 return (sshpam_thread_status);
231 signal(SIGCHLD, sshpam_oldsig); 231 ssh_signal(SIGCHLD, sshpam_oldsig);
232 while (waitpid(thread, &status, 0) == -1) { 232 while (waitpid(thread, &status, 0) == -1) {
233 if (errno == EINTR) 233 if (errno == EINTR)
234 continue; 234 continue;