]> granicus.if.org Git - linux-pam/commitdiff
Check return value of setuid to remove glibc warnings. Linux-PAM-1_1_8
authorThorsten Kukuk <kukuk@thkukuk.de>
Mon, 16 Sep 2013 09:48:12 +0000 (11:48 +0200)
committerThorsten Kukuk <kukuk@thkukuk.de>
Mon, 16 Sep 2013 09:48:12 +0000 (11:48 +0200)
* modules/pam_unix/pam_unix_acct.c: Check setuid return value.
* modules/pam_unix/support.c: Likewise.

modules/pam_unix/pam_unix_acct.c
modules/pam_unix/support.c

index 865dc2903ac09d90269becaa52479439d150b8a9..8ec444926151dbf20b5ac12be648598b7d7a4650 100644 (file)
@@ -121,7 +121,12 @@ int _unix_run_verify_binary(pam_handle_t *pamh, unsigned int ctrl,
     if (geteuid() == 0) {
       /* must set the real uid to 0 so the helper will not error
          out if pam is called from setuid binary (su, sudo...) */
-      setuid(0);
+      if (setuid(0) == -1) {
+          pam_syslog(pamh, LOG_ERR, "setuid failed: %m");
+          printf("-1\n");
+          fflush(stdout);
+          _exit(PAM_AUTHINFO_UNAVAIL);
+      }
     }
 
     /* exec binary helper */
index 9284dbaa08f4a4422a8f2493b3dd266d930e73b3..19d72e66686ed7bc0c5cafc9e01f4f50f9e95505 100644 (file)
@@ -586,7 +586,10 @@ static int _unix_run_helper_binary(pam_handle_t *pamh, const char *passwd,
        if (geteuid() == 0) {
           /* must set the real uid to 0 so the helper will not error
             out if pam is called from setuid binary (su, sudo...) */
-         setuid(0);
+         if (setuid(0) == -1) {
+             D(("setuid failed"));
+            _exit(PAM_AUTHINFO_UNAVAIL);
+          }
        }
 
        /* exec binary helper */