summaryrefslogtreecommitdiff
path: root/auth-pam.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2004-05-28 20:45:33 +0000
committerColin Watson <cjwatson@debian.org>2004-05-28 20:45:33 +0000
commitdf50fe11f12e61af3f371588ba2d637eeac8b8fc (patch)
tree279b5428dc3a62717db8e49c4e6492c67bba8857 /auth-pam.c
parentd42be459d3286ec659fe34acc88a5f005d99d20b (diff)
Kill off PAM thread if privsep slave dies (closes: #248125).
Diffstat (limited to 'auth-pam.c')
-rw-r--r--auth-pam.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/auth-pam.c b/auth-pam.c
index 36dbb7e15..361573807 100644
--- a/auth-pam.c
+++ b/auth-pam.c
@@ -93,10 +93,17 @@ static mysig_t sshpam_oldsig;
93static void 93static void
94sshpam_sigchld_handler(int sig) 94sshpam_sigchld_handler(int sig)
95{ 95{
96 signal(SIGCHLD, SIG_DFL);
96 if (cleanup_ctxt == NULL) 97 if (cleanup_ctxt == NULL)
97 return; /* handler called after PAM cleanup, shouldn't happen */ 98 return; /* handler called after PAM cleanup, shouldn't happen */
98 if (waitpid(cleanup_ctxt->pam_thread, &sshpam_thread_status, 0) == -1) 99 if (waitpid(cleanup_ctxt->pam_thread, &sshpam_thread_status, WNOHANG)
99 return; /* couldn't wait for process */ 100 == -1) {
101 /* PAM thread has not exitted, privsep slave must have */
102 kill(cleanup_ctxt->pam_thread, SIGTERM);
103 if (waitpid(cleanup_ctxt->pam_thread, &sshpam_thread_status, 0)
104 == -1)
105 return; /* could not wait */
106 }
100 if (WIFSIGNALED(sshpam_thread_status) && 107 if (WIFSIGNALED(sshpam_thread_status) &&
101 WTERMSIG(sshpam_thread_status) == SIGTERM) 108 WTERMSIG(sshpam_thread_status) == SIGTERM)
102 return; /* terminated by pthread_cancel */ 109 return; /* terminated by pthread_cancel */