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

Commitcc63e6a

Browse files
tglsfdcpull[bot]
authored andcommitted
Fix missed corner cases for grantable permissions on GUCs.
We allow users to set the values of not-yet-loaded extension GUCs,remembering those values in "placeholder" GUC entries. When/ifthe extension is loaded later in the session, we need to verify thatthe user had permissions to set the GUC. That was done correctlybefore commita0ffa88, but as of that commit, we'd check thepermissions of the active role when the LOAD happens, not the rolethat had set the value. (This'd be a security bug if it had made itinto a released version.)In principle this is simple enough to fix: we just need to rememberthe exact role OID that set each GUC value, and use that notGetUserID() when verifying permissions. Maintaining that data inthe guc.c data structures is slightly tedious, but fortunately it'sall basically just copy-n-paste of the logic for tracking theGucSource of each setting, as we were already doing.Another oversight is that validate_option_array_item() hadn'tbeen taught to check for granted GUC privileges. This appearsto manifest only in that ALTER ROLE/DATABASE RESET ALL willfail to reset settings that the user should be allowed to reset.Patch by myself and Nathan Bossart, per report from Nathan Bossart.Back-patch to v15 where the faulty code came in.Discussion:https://postgr.es/m/20220706224727.GA2158260@nathanxps13
1 parent7dd0e12 commitcc63e6a

File tree

8 files changed

+280
-59
lines changed

8 files changed

+280
-59
lines changed

‎src/backend/commands/extension.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,9 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
912912
* We use the equivalent of a function SET option to allow the setting to
913913
* persist for exactly the duration of the script execution. guc.c also
914914
* takes care of undoing the setting on error.
915+
*
916+
* log_min_messages can't be set by ordinary users, so for that one we
917+
* pretend to be superuser.
915918
*/
916919
save_nestlevel=NewGUCNestLevel();
917920

@@ -920,9 +923,10 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
920923
PGC_USERSET,PGC_S_SESSION,
921924
GUC_ACTION_SAVE, true,0, false);
922925
if (log_min_messages<WARNING)
923-
(void)set_config_option("log_min_messages","warning",
924-
PGC_SUSET,PGC_S_SESSION,
925-
GUC_ACTION_SAVE, true,0, false);
926+
(void)set_config_option_ext("log_min_messages","warning",
927+
PGC_SUSET,PGC_S_SESSION,
928+
BOOTSTRAP_SUPERUSERID,
929+
GUC_ACTION_SAVE, true,0, false);
926930

927931
/*
928932
* Similarly disable check_function_bodies, to ensure that SQL functions

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp