diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2002-07-09 04:44:18 +0000 |
---|---|---|
committer | Andrew G. Morgan <morgan@kernel.org> | 2002-07-09 04:44:18 +0000 |
commit | 067affee9267fa0d1c21835182ba639ba33e820f (patch) | |
tree | 71f8a6dc2703f7d650d0e2880ec931e86f1b7ca3 /modules/pam_unix/unix_chkpwd.c | |
parent | cda1a99dcb3ef18f21bc5cb2b3994e160ec51118 (diff) | |
download | pam-067affee9267fa0d1c21835182ba639ba33e820f.tar.gz pam-067affee9267fa0d1c21835182ba639ba33e820f.tar.bz2 pam-067affee9267fa0d1c21835182ba639ba33e820f.zip |
Relevant BUGIDs: 521314
Purpose of commit: bugfix
Commit summary:
---------------
bigcrypt does not match crypt when password length is too long.
This led to a pam_unix problem when the module had not set the
password in bigcrypt mode, but was trying to compare with bigcrypt
output. The fix is to use the stored password as a guide to how much
of the encrypted password to compare against.
Diffstat (limited to 'modules/pam_unix/unix_chkpwd.c')
-rw-r--r-- | modules/pam_unix/unix_chkpwd.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/pam_unix/unix_chkpwd.c b/modules/pam_unix/unix_chkpwd.c index 9581d046..9ba11041 100644 --- a/modules/pam_unix/unix_chkpwd.c +++ b/modules/pam_unix/unix_chkpwd.c @@ -149,7 +149,16 @@ static int _unix_verify_password(const char *name, const char *p, int opt) } } else { pp = bigcrypt(p, salt); - if (strcmp(pp, salt) == 0) { + /* + * Note, we are comparing the bigcrypt of the password with + * the contents of the password field. If the latter was + * encrypted with regular crypt (and not bigcrypt) it will + * have been truncated for storage relative to the output + * of bigcrypt here. As such we need to compare only the + * stored string with the subset of bigcrypt's result. + * Bug 521314: the strncmp comparison is for legacy support. + */ + if (strncmp(pp, salt, strlen(salt)) == 0) { retval = UNIX_PASSED; } } |