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

Commit0c8910a

Browse files
committed
Teach SHOW ALL to honor pg_read_all_settings membership
Also, fix the pg_settings view to display source filename and linenumber when invoked by a pg_read_all_settings member. This addition byme (Álvaro).Also, fix wording of the comment in GetConfigOption regarding therestriction it implements, renaming the parameter for extra clarity.Noted by Michaël.These were all oversight in commit25fff40; backpatch to pg10,where that commit first appeared.Author: Laurenz AlbeReviewed-by: Michaël Paquier, Álvaro HerreraDiscussion:https://postgr.es/m/1519917758.6586.8.camel@cybertec.at
1 parentacad8b4 commit0c8910a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

‎src/backend/utils/misc/guc.c‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6930,15 +6930,15 @@ SetConfigOption(const char *name, const char *value,
69306930
* this cannot be distinguished from a string variable with a NULL value!),
69316931
* otherwise throw an ereport and don't return.
69326932
*
6933-
* Ifrestrict_superuser is true, we also enforce that only superuserscan
6934-
*see GUC_SUPERUSER_ONLY variables. This should only be passed as true
6935-
* in user-driven calls.
6933+
* Ifrestrict_privileged is true, we also enforce that only superusersand
6934+
*members of the pg_read_all_settings role can see GUC_SUPERUSER_ONLY
6935+
*variables. This should only be passed as truein user-driven calls.
69366936
*
69376937
* The string is *not* allocated for modification and is really only
69386938
* valid until the next call to configuration related functions.
69396939
*/
69406940
constchar*
6941-
GetConfigOption(constchar*name,boolmissing_ok,boolrestrict_superuser)
6941+
GetConfigOption(constchar*name,boolmissing_ok,boolrestrict_privileged)
69426942
{
69436943
structconfig_generic*record;
69446944
staticcharbuffer[256];
@@ -6953,7 +6953,7 @@ GetConfigOption(const char *name, bool missing_ok, bool restrict_superuser)
69536953
errmsg("unrecognized configuration parameter \"%s\"",
69546954
name)));
69556955
}
6956-
if (restrict_superuser&&
6956+
if (restrict_privileged&&
69576957
(record->flags&GUC_SUPERUSER_ONLY)&&
69586958
!is_member_of_role(GetUserId(),DEFAULT_ROLE_READ_ALL_SETTINGS))
69596959
ereport(ERROR,
@@ -8242,7 +8242,6 @@ ShowGUCConfigOption(const char *name, DestReceiver *dest)
82428242
staticvoid
82438243
ShowAllGUCConfig(DestReceiver*dest)
82448244
{
8245-
boolam_superuser=superuser();
82468245
inti;
82478246
TupOutputState*tstate;
82488247
TupleDesctupdesc;
@@ -8267,7 +8266,8 @@ ShowAllGUCConfig(DestReceiver *dest)
82678266
char*setting;
82688267

82698268
if ((conf->flags&GUC_NO_SHOW_ALL)||
8270-
((conf->flags&GUC_SUPERUSER_ONLY)&& !am_superuser))
8269+
((conf->flags&GUC_SUPERUSER_ONLY)&&
8270+
!is_member_of_role(GetUserId(),DEFAULT_ROLE_READ_ALL_SETTINGS)))
82718271
continue;
82728272

82738273
/* assign to the values array */
@@ -8593,9 +8593,10 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
85938593
/*
85948594
* If the setting came from a config file, set the source location. For
85958595
* security reasons, we don't show source file/line number for
8596-
*non-superusers.
8596+
*insufficiently-privileged users.
85978597
*/
8598-
if (conf->source==PGC_S_FILE&&superuser())
8598+
if (conf->source==PGC_S_FILE&&
8599+
is_member_of_role(GetUserId(),DEFAULT_ROLE_READ_ALL_SETTINGS))
85998600
{
86008601
values[14]=conf->sourcefile;
86018602
snprintf(buffer,sizeof(buffer),"%d",conf->sourceline);

‎src/include/utils/guc.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ extern void DefineCustomEnumVariable(
347347
externvoidEmitWarningsOnPlaceholders(constchar*className);
348348

349349
externconstchar*GetConfigOption(constchar*name,boolmissing_ok,
350-
boolrestrict_superuser);
350+
boolrestrict_privileged);
351351
externconstchar*GetConfigOptionResetString(constchar*name);
352352
externintGetConfigOptionFlags(constchar*name,boolmissing_ok);
353353
externvoidProcessConfigFile(GucContextcontext);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp