Skip to content

Commit

Permalink
pam_unix: Add support for crypt_checksalt, if libcrypt supports it.
Browse files Browse the repository at this point in the history
libxcrypt v4.3 has added the crypt_checksalt function to whether
the prefix at the begining of a given hash string refers to a
supported hashing method.

Future revisions of this function will add support to check whether
the hashing method, the prefix refers to, was disabled or considered
deprecated by the system's factory presets or system administrator.
Furthermore it will be able to detect whether the parameters, which
are used by the corresponding hashing method, being encoded in the
hash string are not considered to be strong enough anymore.

*modules/pam_unix/passverify.c: Add support for crypt_checksalt.
  • Loading branch information
besser82 authored and t8m committed Nov 22, 2018
1 parent dce80b3 commit 4da9feb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions modules/pam_unix/passverify.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,13 @@ PAMH_ARG_DECL(int check_shadow_expiry,
D(("account expired"));
return PAM_ACCT_EXPIRED;
}
#if defined(CRYPT_CHECKSALT_AVAILABLE) && CRYPT_CHECKSALT_AVAILABLE
if (spent->sp_lstchg == 0 ||
crypt_checksalt(spent->sp_pwdp) == CRYPT_SALT_METHOD_LEGACY ||
crypt_checksalt(spent->sp_pwdp) == CRYPT_SALT_TOO_CHEAP) {
#else
if (spent->sp_lstchg == 0) {
#endif
D(("need a new password"));
*daysleft = 0;
return PAM_NEW_AUTHTOK_REQD;
Expand All @@ -255,10 +261,19 @@ PAMH_ARG_DECL(int check_shadow_expiry,
spent->sp_namp);
return PAM_SUCCESS;
}
#if defined(CRYPT_CHECKSALT_AVAILABLE) && CRYPT_CHECKSALT_AVAILABLE
if (((curdays - spent->sp_lstchg > spent->sp_max)
&& (curdays - spent->sp_lstchg > spent->sp_inact)
&& (curdays - spent->sp_lstchg > spent->sp_max + spent->sp_inact)
&& (spent->sp_max != -1) && (spent->sp_inact != -1))
|| (crypt_checksalt(spent->sp_pwdp) == CRYPT_SALT_METHOD_DISABLED)
|| (crypt_checksalt(spent->sp_pwdp) == CRYPT_SALT_INVALID)) {
#else
if ((curdays - spent->sp_lstchg > spent->sp_max)
&& (curdays - spent->sp_lstchg > spent->sp_inact)
&& (curdays - spent->sp_lstchg > spent->sp_max + spent->sp_inact)
&& (spent->sp_max != -1) && (spent->sp_inact != -1)) {
#endif
*daysleft = (int)((spent->sp_lstchg + spent->sp_max) - curdays);
D(("authtok expired"));
return PAM_AUTHTOK_EXPIRED;
Expand Down

0 comments on commit 4da9feb

Please sign in to comment.