]> git.armaanb.net Git - opendoas.git/blobdiff - pam.c
doas: remove unnecessary configure checks, move shadow to its own file
[opendoas.git] / pam.c
diff --git a/pam.c b/pam.c
index af038dd5987aae8ac30beb495c9f2f0771d15e5b..6be44b70e2f517b4f1f1e969594e87935bd4ae5d 100644 (file)
--- a/pam.c
+++ b/pam.c
  */
 
 #include <sys/types.h>
+
 #include <err.h>
 #include <errno.h>
+#include <limits.h>
 #include <pwd.h>
+#ifdef HAVE_READPASSPHRASE_H
+#      include <readpassphrase.h>
+#else
+#      include "readpassphrase.h"
+#endif
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/wait.h>
-#include <signal.h>
-#ifdef __linux__
-#include <limits.h>
-#endif
+#include <unistd.h>
 
 #include <security/pam_appl.h>
 
-#include "doas.h"
 #include "includes.h"
 
 #define PAM_SERVICE_NAME "doas"
@@ -191,7 +194,7 @@ watchsession(pid_t child)
                status = 1;
 
 close:
-       if (caught_signal) {
+       if (caught_signal && child != (pid_t)-1) {
                fprintf(stderr, "\nSession terminated, killing shell\n");
                kill(child, SIGTERM);
        }
@@ -199,10 +202,12 @@ close:
        pamcleanup(PAM_SUCCESS);
 
        if (caught_signal) {
-               /* kill child */
-               sleep(2);
-               kill(child, SIGKILL);
-               fprintf(stderr, " ...killed.\n");
+               if (child != (pid_t)-1) {
+                       /* kill child */
+                       sleep(2);
+                       kill(child, SIGKILL);
+                       fprintf(stderr, " ...killed.\n");
+               }
 
                /* unblock cached signal and resend */
                sigaction(SIGTERM, &oldact, NULL);