Fix md5_password_warnings for role and database settings

MD5 authentication warnings are queued during authentication, before
startup options and role/database settings have been applied. The code
checked md5_password_warnings at queue time, so settings such as
ALTER ROLE ... SET md5_password_warnings = off did not suppress the
warning, even though the established session showed the GUC as off.

Keep the connection-warning infrastructure generic by allowing each
queued warning to carry an optional filter callback. Evaluate that
callback when warnings are emitted, after startup options and
role/database settings have been processed.

Use this for MD5 authentication warnings, while leaving password
expiration warnings unchanged. Add test coverage for an MD5-authenticated
role with md5_password_warnings disabled.

Author: Chao Li <[email protected]>
Reviewed-by: Japin Li <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Discussion: https://postgr.es/m/[email protected]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/44196fd4f378d776c4cd7282256f4d6df03b5734

Modified Files
--------------
src/backend/libpq/crypt.c                 | 31 ++++++++++--------
src/backend/utils/init/postinit.c         | 52 ++++++++++++++++++++-----------
src/include/miscadmin.h                   |  4 ++-
src/test/authentication/t/001_password.pl | 17 ++++++++++
src/tools/pgindent/typedefs.list          |  1 +
5 files changed, 72 insertions(+), 33 deletions(-)

Reply via email to