]> granicus.if.org Git - linux-pam/commitdiff
Relevant BUGIDs:
authorThorsten Kukuk <kukuk@thkukuk.de>
Wed, 14 Apr 2010 10:22:10 +0000 (10:22 +0000)
committerThorsten Kukuk <kukuk@thkukuk.de>
Wed, 14 Apr 2010 10:22:10 +0000 (10:22 +0000)
Purpose of commit: bugfix

Commit summary:
---------------

2010-04-13  Thorsten Kukuk  <kukuk@thkukuk.de>

        * modules/pam_pwhistory/opasswd.c: Fix compilation if
        cyprt_r() is not available.
        * configure.in: check for getutent_r.
        * modules/pam_timestamp/pam_timestamp.c: Use getutent()
        if getutent_r() does not exist.
        Patch from Diego Elio "Flameeyes" Pettenò.

ChangeLog
configure.in
modules/pam_pwhistory/opasswd.c
modules/pam_timestamp/pam_timestamp.c

index 23181073ad18f76c0d076168bf79bd9ad16e1c6b..dd7468ae53fa7c3f63801d89bcc2a6fd7e7ce2f6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-04-13  Thorsten Kukuk  <kukuk@thkukuk.de>
+
+       * modules/pam_pwhistory/opasswd.c: Fix compilation if
+       cyprt_r() is not available.
+       * configure.in: check for getutent_r.
+       * modules/pam_timestamp/pam_timestamp.c: Use getutent()
+       if getutent_r() does not exist.
+       Patch from Diego Elio “Flameeyes” Pettenò.
+
 2010-04-12  Thorsten Kukuk  <kukuk@thkukuk.de>
 
        * doc/man/pam.conf-syntax.xml: Better documentation of
index c7c07ccc59f71435b7df4fb905a05ae45c5d61b5..0de55536e31cd29d9364f5a055f1645dadb2fc90 100644 (file)
@@ -458,7 +458,7 @@ AC_FUNC_MEMCMP
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS(fseeko gethostname gettimeofday lckpwdf mkdir select)
 AC_CHECK_FUNCS(strcspn strdup strspn strstr strtol uname)
-AC_CHECK_FUNCS(getpwnam_r getpwuid_r getgrnam_r getgrgid_r getspnam_r)
+AC_CHECK_FUNCS(getutent_r getpwnam_r getpwuid_r getgrnam_r getgrgid_r getspnam_r)
 AC_CHECK_FUNCS(getgrouplist getline getdelim)
 AC_CHECK_FUNCS(inet_ntop inet_pton ruserok_af)
 
index 3c8e5cffff5976889f6519907eeeb97c98933c51..f045555f6528e8e758a19d243884202dab9a94fa 100644 (file)
@@ -94,6 +94,23 @@ parse_entry (char *line, opwd *data)
   return 0;
 }
 
+static int
+compare_password(const char *newpass, const char *oldpass)
+{
+  char *outval;
+#ifdef HAVE_CRYPT_R
+  struct crypt_data output;
+
+  output.initialized = 0;
+
+  outval = crypt_r (newpass, oldpass, &output);
+#else
+  outval = crypt (newpass, oldpass);
+#endif
+
+  return strcmp(outval, oldpass) == 0;
+}
+
 /* Check, if the new password is already in the opasswd file.  */
 int
 check_old_password (pam_handle_t *pamh, const char *user,
@@ -167,12 +184,9 @@ check_old_password (pam_handle_t *pamh, const char *user,
   if (found)
     {
       const char delimiters[] = ",";
-      struct crypt_data output;
       char *running;
       char *oldpass;
 
-      memset (&output, 0, sizeof (output));
-
       running = strdupa (entry.old_passwords);
       if (running == NULL)
        return PAM_BUF_ERR;
@@ -180,7 +194,7 @@ check_old_password (pam_handle_t *pamh, const char *user,
       do {
        oldpass = strsep (&running, delimiters);
        if (oldpass && strlen (oldpass) > 0 &&
-           strcmp (crypt_r (newpass, oldpass, &output), oldpass) == 0)
+           compare_password(newpass, oldpass) )
          {
            if (debug)
              pam_syslog (pamh, LOG_DEBUG, "New password already used");
index 7e6c4b0bbe3c189b5bb4268511da7a2cf84b312d..268767699ef5e755c2a396c5f0a4e1f34d4ed6ab 100644 (file)
@@ -200,7 +200,13 @@ check_login_time(const char *ruser, time_t timestamp)
        time_t oldest_login = 0;
 
        setutent();
-       while(!getutent_r(&utbuf, &ut)) {
+       while(
+#ifdef HAVE_GETUTENT_R
+             !getutent_r(&utbuf, &ut)
+#else
+             (ut = getutent()) != NULL
+#endif
+             ) {
                if (ut->ut_type != USER_PROCESS) {
                        continue;
                }