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

Commit7d8167b

Browse files
committed
pathman_post_parse_analysis_hook(): improve 'shared_preload_libraries' check (issue #82)
1 parent13e8aef commit7d8167b

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

‎src/hooks.c‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include"xact_handling.h"
2121

2222
#include"access/transam.h"
23+
#include"catalog/pg_authid.h"
2324
#include"miscadmin.h"
2425
#include"optimizer/cost.h"
2526
#include"optimizer/restrictinfo.h"
@@ -556,14 +557,33 @@ pathman_post_parse_analysis_hook(ParseState *pstate, Query *query)
556557
/* Check that pg_pathman is the last extension loaded */
557558
if (post_parse_analyze_hook!=pathman_post_parse_analysis_hook)
558559
{
559-
char*spl_value;/* value of "shared_preload_libraries" GUC */
560+
Oidsave_userid;
561+
intsave_sec_context;
562+
boolneed_priv_escalation= !superuser();/* we might be a SU */
563+
char*spl_value;/* value of "shared_preload_libraries" GUC */
560564

565+
/* Do we have to escalate privileges? */
566+
if (need_priv_escalation)
567+
{
568+
/* Get current user's Oid and security context */
569+
GetUserIdAndSecContext(&save_userid,&save_sec_context);
570+
571+
/* Become superuser in order to bypass sequence ACL checks */
572+
SetUserIdAndSecContext(BOOTSTRAP_SUPERUSERID,
573+
save_sec_context |SECURITY_LOCAL_USERID_CHANGE);
574+
}
575+
576+
/* Only SU can read this GUC */
561577
#ifPG_VERSION_NUM >=90600
562578
spl_value=GetConfigOptionByName("shared_preload_libraries",NULL, false);
563579
#else
564580
spl_value=GetConfigOptionByName("shared_preload_libraries",NULL);
565581
#endif
566582

583+
/* Restore user's privileges */
584+
if (need_priv_escalation)
585+
SetUserIdAndSecContext(save_userid,save_sec_context);
586+
567587
ereport(ERROR,
568588
(errmsg("extension conflict has been detected"),
569589
errdetail("shared_preload_libraries = \"%s\"",spl_value),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp