~ubuntu-branches/ubuntu/oneiric/pam/oneiric-proposed

« back to all changes in this revision

Viewing changes to modules/pam_pwhistory/opasswd.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-02-17 16:15:47 UTC
  • mfrom: (3.2.15 sid)
  • Revision ID: james.westby@ubuntu.com-20110217161547-afxi0yboxvn18a5t
Tags: 1.1.2-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/libpam-modules.postinst: Add PATH to /etc/environment if it's
    not present there or in /etc/security/pam_env.conf. (should send to
    Debian).
  - debian/libpam0g.postinst: only ask questions during update-manager when
    there are non-default services running.
  - debian/patches-applied/series: Ubuntu patches are as below ...
  - debian/patches-applied/ubuntu-rlimit_nice_correction: Explicitly
    initialise RLIMIT_NICE rather than relying on the kernel limits.
  - Change Vcs-Bzr to point at the Ubuntu branch.
  - debian/patches-applied/pam_motd-legal-notice: display the contents of
    /etc/legal once, then set a flag in the user's homedir to prevent
    showing it again.
  - debian/update-motd.5, debian/libpam-modules.manpages: add a manpage
    for update-motd, with some best practices and notes of explanation.
  - debian/patches/update-motd-manpage-ref: add a reference in pam_motd(8)
    to update-motd(5)

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
  return 0;
95
95
}
96
96
 
 
97
static int
 
98
compare_password(const char *newpass, const char *oldpass)
 
99
{
 
100
  char *outval;
 
101
#ifdef HAVE_CRYPT_R
 
102
  struct crypt_data output;
 
103
 
 
104
  output.initialized = 0;
 
105
 
 
106
  outval = crypt_r (newpass, oldpass, &output);
 
107
#else
 
108
  outval = crypt (newpass, oldpass);
 
109
#endif
 
110
 
 
111
  return strcmp(outval, oldpass) == 0;
 
112
}
 
113
 
97
114
/* Check, if the new password is already in the opasswd file.  */
98
115
int
99
116
check_old_password (pam_handle_t *pamh, const char *user,
167
184
  if (found)
168
185
    {
169
186
      const char delimiters[] = ",";
170
 
      struct crypt_data output;
171
187
      char *running;
172
188
      char *oldpass;
173
189
 
174
 
      memset (&output, 0, sizeof (output));
175
 
 
176
190
      running = strdupa (entry.old_passwords);
177
191
      if (running == NULL)
178
192
        return PAM_BUF_ERR;
180
194
      do {
181
195
        oldpass = strsep (&running, delimiters);
182
196
        if (oldpass && strlen (oldpass) > 0 &&
183
 
            strcmp (crypt_r (newpass, oldpass, &output), oldpass) == 0)
 
197
            compare_password(newpass, oldpass) )
184
198
          {
185
199
            if (debug)
186
200
              pam_syslog (pamh, LOG_DEBUG, "New password already used");