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

Commitb2a3d70

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 parent07b3908 commitb2a3d70

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
@@ -26,10 +26,14 @@
2626

2727
PG_MODULE_MAGIC;
2828

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

3235
externvoid_PG_init(void);
36+
externvoid_PG_fini(void);
3337

3438
/*
3539
* check_password
@@ -55,6 +59,11 @@ check_password(const char *username,
5559
Datumvaliduntil_time,
5660
boolvaliduntil_null)
5761
{
62+
if (prev_check_password_hook)
63+
prev_check_password_hook(username,shadow_pass,
64+
password_type,validuntil_time,
65+
validuntil_null);
66+
5867
if (password_type!=PASSWORD_TYPE_PLAINTEXT)
5968
{
6069
/*
@@ -133,5 +142,16 @@ void
133142
_PG_init(void)
134143
{
135144
/* activate password checks when the module is loaded */
145+
prev_check_password_hook=check_password_hook;
136146
check_password_hook=check_password;
137147
}
148+
149+
/*
150+
* Module unload function
151+
*/
152+
void
153+
_PG_fini(void)
154+
{
155+
/* uninstall hook */
156+
check_password_hook=prev_check_password_hook;
157+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp