]> andersk Git - openssh.git/commitdiff
- (dtucker) [auth-pam.c] Have monitor die if PAM authentication thread exits
authordtucker <dtucker>
Wed, 14 Jan 2004 11:14:04 +0000 (11:14 +0000)
committerdtucker <dtucker>
Wed, 14 Jan 2004 11:14:04 +0000 (11:14 +0000)
   unexpectedly.  with & ok djm@

ChangeLog
auth-pam.c

index 58ad89c3b156b7725b1f78a827d660382d0e544e..0759caac02f49f4b5476b8084df278322fd04cc5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+20040114
+ - (dtucker) [auth-pam.c] Have monitor die if PAM authentication thread exits
+   unexpectedly.  with & ok djm@
+
 20040113
  - (dtucker) [auth-pam.c] Relocate struct pam_ctxt and prototypes.  No
    functional changes.
index 80e00c3b08947a997b6ce342a876979c7365bab5..3b363c26c302dfff019b5e86bfa366df4431c4c2 100644 (file)
@@ -86,6 +86,23 @@ static struct pam_ctxt *cleanup_ctxt;
  * Simulate threads with processes.
  */
 
+static int sshpam_thread_status = -1;
+static mysig_t sshpam_oldsig;
+
+static void 
+sshpam_sigchld_handler(int sig)
+{
+       if (waitpid(cleanup_ctxt->pam_thread, &sshpam_thread_status, 0) == -1)
+               return; /* couldn't wait for process */
+       if (WIFSIGNALED(sshpam_thread_status) &&
+           WTERMSIG(sshpam_thread_status) == SIGTERM)
+               return; /* terminated by pthread_cancel */
+       if (!WIFEXITED(sshpam_thread_status))
+               fatal("PAM: authentication thread exited unexpectedly");
+       if (WEXITSTATUS(sshpam_thread_status) != 0)
+               fatal("PAM: authentication thread exited uncleanly");
+}
+
 static void
 pthread_exit(void *value __unused)
 {
@@ -107,6 +124,7 @@ pthread_create(sp_pthread_t *thread, const void *attr __unused,
                _exit(1);
        default:
                *thread = pid;
+               sshpam_oldsig = signal(SIGCHLD, sshpam_sigchld_handler);
                return (0);
        }
 }
@@ -122,6 +140,9 @@ pthread_join(sp_pthread_t thread, void **value __unused)
 {
        int status;
 
+       if (sshpam_thread_status != -1)
+               return (sshpam_thread_status);
+       signal(SIGCHLD, sshpam_oldsig);
        waitpid(thread, &status, 0);
        return (status);
 }
This page took 0.04739 seconds and 5 git commands to generate.