]> granicus.if.org Git - linux-pam/blobdiff - modules/pam_unix/support.c
Relevant BUGIDs: none
[linux-pam] / modules / pam_unix / support.c
index 5368ae20832a528aa38e83f241ef0761cee00de7..fc7fc2b337a41272310e44946ddc41c125b39376 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright information at end of file.
  */
 
-#define _BSD_SOURCE
+#include "config.h"
 
 #include <stdlib.h>
 #include <unistd.h>
@@ -19,6 +19,7 @@
 #include <errno.h>
 #include <signal.h>
 #include <ctype.h>
+#include <sys/resource.h>
 #include <rpcsvc/ypclnt.h>
 
 #include <security/_pam_macros.h>
@@ -713,15 +714,10 @@ int _unix_verify_password(pam_handle_t * pamh, const char *name
        retval = PAM_SUCCESS;
        if (pwd == NULL || salt == NULL || !strcmp(salt, "x") || ((salt[0] == '#') && (salt[1] == '#') && !strcmp(salt + 2, name))) {
 
-               if (geteuid() || SELINUX_ENABLED) {
+               if (pwd != NULL && (geteuid() || SELINUX_ENABLED)) {
                        /* we are not root perhaps this is the reason? Run helper */
                        D(("running helper binary"));
                        retval = _unix_run_helper_binary(pamh, p, ctrl, name);
-                       if (pwd == NULL && !on(UNIX_AUDIT,ctrl)
-                           && retval != PAM_SUCCESS)
-                       {
-                               name = NULL;
-                       }
                } else {
                        D(("user's record unavailable"));
                        p = NULL;
@@ -820,8 +816,11 @@ int _unix_verify_password(pam_handle_t * pamh, const char *name
                                new->name = x_strdup(login_name);
 
                                /* any previous failures for this user ? */
-                               pam_get_data(pamh, data_name, &void_old);
-                               old = void_old;
+                               if (pam_get_data(pamh, data_name, &void_old)
+                                   == PAM_SUCCESS)
+                                       old = void_old;
+                               else
+                                       old = NULL;
 
                                if (old != NULL) {
                                        new->count = old->count + 1;