aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/passwordcheck/passwordcheck.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/contrib/passwordcheck/passwordcheck.c b/contrib/passwordcheck/passwordcheck.c
index 78c44b2d05c..8c8c3bb517d 100644
--- a/contrib/passwordcheck/passwordcheck.c
+++ b/contrib/passwordcheck/passwordcheck.c
@@ -26,10 +26,14 @@
PG_MODULE_MAGIC;
+/* Saved hook value in case of unload */
+static check_password_hook_type prev_check_password_hook = NULL;
+
/* passwords shorter than this will be rejected */
#define MIN_PWD_LENGTH 8
extern void _PG_init(void);
+extern void _PG_fini(void);
/*
* check_password
@@ -62,6 +66,11 @@ check_password(const char *username,
bool pwd_has_letter,
pwd_has_nonletter;
+ if (prev_check_password_hook)
+ prev_check_password_hook(username, password,
+ password_type, validuntil_time,
+ validuntil_null);
+
switch (password_type)
{
case PASSWORD_TYPE_MD5:
@@ -143,5 +152,16 @@ void
_PG_init(void)
{
/* activate password checks when the module is loaded */
+ prev_check_password_hook = check_password_hook;
check_password_hook = check_password;
}
+
+/*
+ * Module unload function
+ */
+void
+_PG_fini(void)
+{
+ /* uninstall hook */
+ check_password_hook = prev_check_password_hook;
+}