Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteea28a3

Browse files
committed
Fix handling of previous password hooks in passwordcheck
When piling up loading of modules using check_password_hook_type,loading passwordcheck would remove any trace of a previously-loadedhook. Unloading the module would also cause previous hooks to beentirely gone.Reported-by: Rafael CastroAuthor: Michael PaquierReviewed-by: Daniel GustafssonDiscussion:https://postgr.es/m/15932-78f48f9ef166778c@postgresql.orgBackpatch-through: 9.4
1 parent4e10b6f commiteea28a3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎contrib/passwordcheck/passwordcheck.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@
2727

2828
PG_MODULE_MAGIC;
2929

30+
/* Saved hook value in case of unload */
31+
staticcheck_password_hook_typeprev_check_password_hook=NULL;
32+
3033
/* passwords shorter than this will be rejected */
3134
#defineMIN_PWD_LENGTH 8
3235

3336
externvoid_PG_init(void);
37+
externvoid_PG_fini(void);
3438

3539
/*
3640
* check_password
@@ -63,6 +67,11 @@ check_password(const char *username,
6367
boolpwd_has_letter,
6468
pwd_has_nonletter;
6569

70+
if (prev_check_password_hook)
71+
prev_check_password_hook(username,password,
72+
password_type,validuntil_time,
73+
validuntil_null);
74+
6675
switch (password_type)
6776
{
6877
casePASSWORD_TYPE_MD5:
@@ -144,5 +153,16 @@ void
144153
_PG_init(void)
145154
{
146155
/* activate password checks when the module is loaded */
156+
prev_check_password_hook=check_password_hook;
147157
check_password_hook=check_password;
148158
}
159+
160+
/*
161+
* Module unload function
162+
*/
163+
void
164+
_PG_fini(void)
165+
{
166+
/* uninstall hook */
167+
check_password_hook=prev_check_password_hook;
168+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp