Commit 924123a8 authored by Peter Eisentraut's avatar Peter Eisentraut

passwordcheck: Log cracklib diagnostics

When calling cracklib to check the password, the diagnostic from
cracklib was thrown away.  This would hide essential information such
as no dictionary being installed.  Change this to show the cracklib
error message using errdetail_log().
Reviewed-by: default avatarDaniel Gustafsson <daniel@yesql.se>
Reviewed-by: default avatarLaurenz Albe <laurenz.albe@cybertec.at>
Discussion: https://www.postgresql.org/message-id/flat/f7266133-618a-0adc-52ef-f43c78806b0e%402ndquadrant.com
parent 10564ee0
...@@ -91,6 +91,9 @@ check_password(const char *username, ...@@ -91,6 +91,9 @@ check_password(const char *username,
int i; int i;
bool pwd_has_letter, bool pwd_has_letter,
pwd_has_nonletter; pwd_has_nonletter;
#ifdef USE_CRACKLIB
const char *reason;
#endif
/* enforce minimum length */ /* enforce minimum length */
if (pwdlen < MIN_PWD_LENGTH) if (pwdlen < MIN_PWD_LENGTH)
...@@ -125,10 +128,11 @@ check_password(const char *username, ...@@ -125,10 +128,11 @@ check_password(const char *username,
#ifdef USE_CRACKLIB #ifdef USE_CRACKLIB
/* call cracklib to check password */ /* call cracklib to check password */
if (FascistCheck(password, CRACKLIB_DICTPATH)) if ((reason = FascistCheck(password, CRACKLIB_DICTPATH)))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("password is easily cracked"))); errmsg("password is easily cracked"),
errdetail_log("cracklib diagnostic: %s", reason)));
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment