summaryrefslogtreecommitdiff
path: root/modules/pam_pwhistory/opasswd.c
diff options
context:
space:
mode:
authorThorsten Kukuk <kukuk@thkukuk.de>2010-04-14 10:22:10 +0000
committerThorsten Kukuk <kukuk@thkukuk.de>2010-04-14 10:22:10 +0000
commitf92940aef28c98145ecddeff05b4aa4be7a6c5e5 (patch)
tree2643ec093c7eb7a765979424a460f20e7cd9983d /modules/pam_pwhistory/opasswd.c
parent871a6e14d65c3c446ae0af51166dabc7a47a2b56 (diff)
Relevant BUGIDs:
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ò.
Diffstat (limited to 'modules/pam_pwhistory/opasswd.c')
-rw-r--r--modules/pam_pwhistory/opasswd.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/modules/pam_pwhistory/opasswd.c b/modules/pam_pwhistory/opasswd.c
index 3c8e5cff..f045555f 100644
--- a/modules/pam_pwhistory/opasswd.c
+++ b/modules/pam_pwhistory/opasswd.c
@@ -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");