Skip to content

Commit 924123a

Browse files
committed
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: Daniel Gustafsson <daniel@yesql.se> Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at> Discussion: https://www.postgresql.org/message-id/flat/f7266133-618a-0adc-52ef-f43c78806b0e%402ndquadrant.com
1 parent 10564ee commit 924123a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

contrib/passwordcheck/passwordcheck.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ check_password(const char *username,
9191
int i;
9292
bool pwd_has_letter,
9393
pwd_has_nonletter;
94+
#ifdef USE_CRACKLIB
95+
const char *reason;
96+
#endif
9497

9598
/* enforce minimum length */
9699
if (pwdlen < MIN_PWD_LENGTH)
@@ -125,10 +128,11 @@ check_password(const char *username,
125128

126129
#ifdef USE_CRACKLIB
127130
/* call cracklib to check password */
128-
if (FascistCheck(password, CRACKLIB_DICTPATH))
131+
if ((reason = FascistCheck(password, CRACKLIB_DICTPATH)))
129132
ereport(ERROR,
130133
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
131-
errmsg("password is easily cracked")));
134+
errmsg("password is easily cracked"),
135+
errdetail_log("cracklib diagnostic: %s", reason)));
132136
#endif
133137
}
134138

0 commit comments

Comments
 (0)