Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c9c41c7

Browse files
committed
Rename Default Roles to Predefined Roles
The term 'default roles' wasn't quite apt as these roles aren't able to be modified or removed after installation, so rename them to be 'Predefined Roles' instead, adding an entry into the newly added Obsolete Appendix to help users of current releases find the new documentation. Bruce Momjian and Stephen Frost Discussion: https://postgr.es/m/157742545062.1149.11052653770497832538%40wrigleys.postgresql.org and https://www.postgresql.org/message-id/20201120211304.GG16415@tamriel.snowman.net
1 parent a68a894 commit c9c41c7

23 files changed

+82
-52
lines changed

contrib/adminpack/adminpack.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,13 @@ convert_and_check_filename(text *arg)
7979
* files on the server as the PG user, so no need to do any further checks
8080
* here.
8181
*/
82-
if (is_member_of_role(GetUserId(), DEFAULT_ROLE_WRITE_SERVER_FILES))
82+
if (is_member_of_role(GetUserId(), ROLE_PG_WRITE_SERVER_FILES))
8383
return filename;
8484

85-
/* User isn't a member of the default role, so check if it's allowable */
85+
/*
86+
* User isn't a member of the pg_write_server_files role, so check if it's
87+
* allowable
88+
*/
8689
if (is_absolute_path(filename))
8790
{
8891
/* Disallow '/a/b/data/..' */

contrib/file_fdw/file_fdw.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,13 @@ file_fdw_validator(PG_FUNCTION_ARGS)
269269
* otherwise there'd still be a security hole.
270270
*/
271271
if (strcmp(def->defname, "filename") == 0 &&
272-
!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_SERVER_FILES))
272+
!is_member_of_role(GetUserId(), ROLE_PG_READ_SERVER_FILES))
273273
ereport(ERROR,
274274
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
275275
errmsg("only superuser or a member of the pg_read_server_files role may specify the filename option of a file_fdw foreign table")));
276276

277277
if (strcmp(def->defname, "program") == 0 &&
278-
!is_member_of_role(GetUserId(), DEFAULT_ROLE_EXECUTE_SERVER_PROGRAM))
278+
!is_member_of_role(GetUserId(), ROLE_PG_EXECUTE_SERVER_PROGRAM))
279279
ereport(ERROR,
280280
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
281281
errmsg("only superuser or a member of the pg_execute_server_program role may specify the program option of a file_fdw foreign table")));

contrib/pg_stat_statements/pg_stat_statements.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
15871587
pgssEntry *entry;
15881588

15891589
/* Superusers or members of pg_read_all_stats members are allowed */
1590-
is_allowed_role = is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS);
1590+
is_allowed_role = is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS);
15911591

15921592
/* hash table must exist already */
15931593
if (!pgss || !pgss_hash)

contrib/pgrowlocks/pgrowlocks.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
130130
aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
131131
ACL_SELECT);
132132
if (aclresult != ACLCHECK_OK)
133-
aclresult = is_member_of_role(GetUserId(), DEFAULT_ROLE_STAT_SCAN_TABLES) ? ACLCHECK_OK : ACLCHECK_NO_PRIV;
133+
aclresult = is_member_of_role(GetUserId(), ROLE_PG_STAT_SCAN_TABLES) ? ACLCHECK_OK : ACLCHECK_NO_PRIV;
134134

135135
if (aclresult != ACLCHECK_OK)
136136
aclcheck_error(aclresult, get_relkind_objtype(rel->rd_rel->relkind),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!-- doc/src/sgml/obsolete-default-roles.sgml -->
2+
<!--
3+
See doc/src/sgml/obsolete.sgml for why this file exists. Do not change the id attribute.
4+
-->
5+
6+
<sect1 id="default-roles" xreflabel="default-roles">
7+
<title>Default Roles renamed to Predefined Roles</title>
8+
9+
<indexterm>
10+
<primary>default-roles</primary>
11+
</indexterm>
12+
13+
<para>
14+
PostgreSQL 13 and below used the term 'Default Roles', however, as these
15+
roles are not able to actually be changed and are installed as part of the
16+
system at initialization time, the more appropriate term to use is "Predefined Roles".
17+
See <xref linkend="predefined-roles"/> for current documentation regarding
18+
Predefined Roles, and <link linkend="release-prior">the release notes for
19+
PostgreSQL 14</link> for details on this change.
20+
</para>
21+
22+
</sect1>

doc/src/sgml/appendix-obsolete.sgml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
-->
3535

3636
&obsolete-recovery-config;
37+
&obsolete-default-roles;
3738
&obsolete-pgxlogdump;
3839
&obsolete-pgresetxlog;
3940
&obsolete-pgreceivexlog;

doc/src/sgml/file-fdw.sgml

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@
187187

188188
<para>
189189
Changing table-level options requires being a superuser or having the privileges
190-
of the default role <literal>pg_read_server_files</literal> (to use a filename) or
191-
the default role <literal>pg_execute_server_program</literal> (to use a program),
190+
of the role <literal>pg_read_server_files</literal> (to use a filename) or
191+
the role <literal>pg_execute_server_program</literal> (to use a program),
192192
for security reasons: only certain users should be able to control which file is
193193
read or which program is run. In principle regular users could be allowed to
194194
change the other options, but that's not supported at present.

doc/src/sgml/filelist.sgml

+1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
<!-- Stubs for removed entries to preserve public links -->
189189
<!ENTITY obsolete SYSTEM "appendix-obsolete.sgml">
190190
<!ENTITY obsolete-recovery-config SYSTEM "appendix-obsolete-recovery-config.sgml">
191+
<!ENTITY obsolete-default-roles SYSTEM "appendix-obsolete-default-roles.sgml">
191192
<!ENTITY obsolete-pgxlogdump SYSTEM "appendix-obsolete-pgxlogdump.sgml">
192193
<!ENTITY obsolete-pgresetxlog SYSTEM "appendix-obsolete-pgresetxlog.sgml">
193194
<!ENTITY obsolete-pgreceivexlog SYSTEM "appendix-obsolete-pgreceivexlog.sgml">

doc/src/sgml/monitoring.sgml

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
282282
existence of a session and its general properties such as its sessions user
283283
and database are visible to all users. Superusers and members of the
284284
built-in role <literal>pg_read_all_stats</literal> (see also <xref
285-
linkend="default-roles"/>) can see all the information about all sessions.
285+
linkend="predefined-roles"/>) can see all the information about all sessions.
286286
</para>
287287

288288
<table id="monitoring-stats-dynamic-views-table">

doc/src/sgml/ref/copy.sgml

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ COPY <replaceable class="parameter">count</replaceable>
465465
by the server, not by the client application, must be executable by the
466466
<productname>PostgreSQL</productname> user.
467467
<command>COPY</command> naming a file or command is only allowed to
468-
database superusers or users who are granted one of the default roles
468+
database superusers or users who are granted one of the roles
469469
<literal>pg_read_server_files</literal>,
470470
<literal>pg_write_server_files</literal>,
471471
or <literal>pg_execute_server_program</literal>, since it allows reading

doc/src/sgml/user-manag.sgml

+9-9
Original file line numberDiff line numberDiff line change
@@ -483,15 +483,15 @@ DROP ROLE doomed_role;
483483
</para>
484484
</sect1>
485485

486-
<sect1 id="default-roles">
487-
<title>Default Roles</title>
486+
<sect1 id="predefined-roles">
487+
<title>Predefined Roles</title>
488488

489-
<indexterm zone="default-roles">
489+
<indexterm zone="predefined-roles">
490490
<primary>role</primary>
491491
</indexterm>
492492

493493
<para>
494-
<productname>PostgreSQL</productname> provides a set of default roles
494+
<productname>PostgreSQL</productname> provides a set of predefined roles
495495
that provide access to certain, commonly needed, privileged capabilities
496496
and information. Administrators (including roles that have the
497497
<literal>CREATEROLE</literal> privilege) can <command>GRANT</command> these
@@ -500,14 +500,14 @@ DROP ROLE doomed_role;
500500
</para>
501501

502502
<para>
503-
The default roles are described in <xref linkend="default-roles-table"/>.
504-
Note that the specific permissions for each of the default roles may
505-
change in the future as additional capabilities are added. Administrators
503+
The predefined roles are described in <xref linkend="predefined-roles-table"/>.
504+
Note that the specific permissions for each of the roles may change in
505+
the future as additional capabilities are added. Administrators
506506
should monitor the release notes for changes.
507507
</para>
508508

509-
<table tocentry="1" id="default-roles-table">
510-
<title>Default Roles</title>
509+
<table tocentry="1" id="predefined-roles-table">
510+
<title>Predefined Roles</title>
511511
<tgroup cols="2">
512512
<colspec colname="col1" colwidth="1*"/>
513513
<colspec colname="col2" colwidth="2*"/>

src/backend/commands/copy.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
8080
{
8181
if (stmt->is_program)
8282
{
83-
if (!is_member_of_role(GetUserId(), DEFAULT_ROLE_EXECUTE_SERVER_PROGRAM))
83+
if (!is_member_of_role(GetUserId(), ROLE_PG_EXECUTE_SERVER_PROGRAM))
8484
ereport(ERROR,
8585
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
8686
errmsg("must be superuser or a member of the pg_execute_server_program role to COPY to or from an external program"),
@@ -89,14 +89,14 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
8989
}
9090
else
9191
{
92-
if (is_from && !is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_SERVER_FILES))
92+
if (is_from && !is_member_of_role(GetUserId(), ROLE_PG_READ_SERVER_FILES))
9393
ereport(ERROR,
9494
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
9595
errmsg("must be superuser or a member of the pg_read_server_files role to COPY from a file"),
9696
errhint("Anyone can COPY to stdout or from stdin. "
9797
"psql's \\copy command also works for anyone.")));
9898

99-
if (!is_from && !is_member_of_role(GetUserId(), DEFAULT_ROLE_WRITE_SERVER_FILES))
99+
if (!is_from && !is_member_of_role(GetUserId(), ROLE_PG_WRITE_SERVER_FILES))
100100
ereport(ERROR,
101101
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
102102
errmsg("must be superuser or a member of the pg_write_server_files role to COPY to a file"),

src/backend/commands/user.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1501,10 +1501,10 @@ AddRoleMems(const char *rolename, Oid roleid,
15011501
* situation-dependent member. There's no technical need for this
15021502
* restriction. (One could lift it and take the further step of making
15031503
* pg_database_ownercheck() equivalent to has_privs_of_role(roleid,
1504-
* DEFAULT_ROLE_DATABASE_OWNER), in which case explicit,
1504+
* ROLE_DATABASE_OWNER), in which case explicit,
15051505
* situation-independent members could act as the owner of any database.)
15061506
*/
1507-
if (roleid == DEFAULT_ROLE_DATABASE_OWNER)
1507+
if (roleid == ROLE_DATABASE_OWNER)
15081508
ereport(ERROR,
15091509
errmsg("role \"%s\" cannot have explicit members", rolename));
15101510

@@ -1555,7 +1555,7 @@ AddRoleMems(const char *rolename, Oid roleid,
15551555
* shared object. (The effect of such ownership is that any owner of
15561556
* another database can act as the owner of affected shared objects.)
15571557
*/
1558-
if (memberid == DEFAULT_ROLE_DATABASE_OWNER)
1558+
if (memberid == ROLE_DATABASE_OWNER)
15591559
ereport(ERROR,
15601560
errmsg("role \"%s\" cannot be a member of any role",
15611561
get_rolespec_name(memberRole)));

src/backend/replication/walreceiver.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
13611361
/* Fetch values */
13621362
values[0] = Int32GetDatum(pid);
13631363

1364-
if (!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS))
1364+
if (!is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS))
13651365
{
13661366
/*
13671367
* Only superusers and members of pg_read_all_stats can see details.

src/backend/replication/walsender.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3355,7 +3355,7 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
33553355
memset(nulls, 0, sizeof(nulls));
33563356
values[0] = Int32GetDatum(pid);
33573357

3358-
if (!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS))
3358+
if (!is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS))
33593359
{
33603360
/*
33613361
* Only superusers and members of pg_read_all_stats can see

src/backend/storage/ipc/procarray.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3752,7 +3752,7 @@ TerminateOtherDBBackends(Oid databaseId)
37523752

37533753
/* Users can signal backends they have role membership in. */
37543754
if (!has_privs_of_role(GetUserId(), proc->roleId) &&
3755-
!has_privs_of_role(GetUserId(), DEFAULT_ROLE_SIGNAL_BACKENDID))
3755+
!has_privs_of_role(GetUserId(), ROLE_PG_SIGNAL_BACKEND))
37563756
ereport(ERROR,
37573757
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
37583758
errmsg("must be a member of the role whose process is being terminated or member of pg_signal_backend")));

src/backend/storage/ipc/signalfuncs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pg_signal_backend(int pid, int sig)
7474

7575
/* Users can signal backends they have role membership in. */
7676
if (!has_privs_of_role(GetUserId(), proc->roleId) &&
77-
!has_privs_of_role(GetUserId(), DEFAULT_ROLE_SIGNAL_BACKENDID))
77+
!has_privs_of_role(GetUserId(), ROLE_PG_SIGNAL_BACKEND))
7878
return SIGNAL_BACKEND_NOPERMISSION;
7979

8080
/*

src/backend/utils/adt/acl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -4741,7 +4741,7 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type,
47414741

47424742
/*
47434743
* Role expansion happens in a non-database backend when guc.c checks
4744-
* DEFAULT_ROLE_READ_ALL_SETTINGS for a physical walsender SHOW command.
4744+
* ROLE_READ_ALL_SETTINGS for a physical walsender SHOW command.
47454745
* In that case, no role gets pg_database_owner.
47464746
*/
47474747
if (!OidIsValid(MyDatabaseId))
@@ -4808,7 +4808,7 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type,
48084808
/* implement pg_database_owner implicit membership */
48094809
if (memberid == dba && OidIsValid(dba))
48104810
roles_list = list_append_unique_oid(roles_list,
4811-
DEFAULT_ROLE_DATABASE_OWNER);
4811+
ROLE_DATABASE_OWNER);
48124812
}
48134813

48144814
/*

src/backend/utils/adt/dbsize.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ calculate_database_size(Oid dbOid)
9595
*/
9696
aclresult = pg_database_aclcheck(dbOid, GetUserId(), ACL_CONNECT);
9797
if (aclresult != ACLCHECK_OK &&
98-
!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS))
98+
!is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS))
9999
{
100100
aclcheck_error(aclresult, OBJECT_DATABASE,
101101
get_database_name(dbOid));
@@ -179,7 +179,7 @@ calculate_tablespace_size(Oid tblspcOid)
179179
* is default for current database.
180180
*/
181181
if (tblspcOid != MyDatabaseTableSpace &&
182-
!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS))
182+
!is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS))
183183
{
184184
aclresult = pg_tablespace_aclcheck(tblspcOid, GetUserId(), ACL_CREATE);
185185
if (aclresult != ACLCHECK_OK)

src/backend/utils/adt/genfile.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ convert_and_check_filename(text *arg)
6262
* files on the server as the PG user, so no need to do any further checks
6363
* here.
6464
*/
65-
if (is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_SERVER_FILES))
65+
if (is_member_of_role(GetUserId(), ROLE_PG_READ_SERVER_FILES))
6666
return filename;
6767

68-
/* User isn't a member of the default role, so check if it's allowable */
68+
/*
69+
* User isn't a member of the pg_read_server_files role, so check if it's
70+
* allowable
71+
*/
6972
if (is_absolute_path(filename))
7073
{
7174
/* Disallow '/a/b/data/..' */

src/backend/utils/adt/pgstatfuncs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#define UINT32_ACCESS_ONCE(var) ((uint32)(*((volatile uint32 *)&(var))))
3535

36-
#define HAS_PGSTAT_PERMISSIONS(role) (is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS) || has_privs_of_role(GetUserId(), role))
36+
#define HAS_PGSTAT_PERMISSIONS(role) (is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS) || has_privs_of_role(GetUserId(), role))
3737

3838
/* Global bgwriter statistics, from bgwriter.c */
3939
extern PgStat_MsgBgWriter bgwriterStats;

src/backend/utils/misc/guc.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -7985,7 +7985,7 @@ GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)
79857985
}
79867986
if (restrict_privileged &&
79877987
(record->flags & GUC_SUPERUSER_ONLY) &&
7988-
!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_SETTINGS))
7988+
!is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
79897989
ereport(ERROR,
79907990
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
79917991
errmsg("must be superuser or a member of pg_read_all_settings to examine \"%s\"",
@@ -8035,7 +8035,7 @@ GetConfigOptionResetString(const char *name)
80358035
(errcode(ERRCODE_UNDEFINED_OBJECT),
80368036
errmsg("unrecognized configuration parameter \"%s\"", name)));
80378037
if ((record->flags & GUC_SUPERUSER_ONLY) &&
8038-
!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_SETTINGS))
8038+
!is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
80398039
ereport(ERROR,
80408040
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
80418041
errmsg("must be superuser or a member of pg_read_all_settings to examine \"%s\"",
@@ -9294,7 +9294,7 @@ ShowAllGUCConfig(DestReceiver *dest)
92949294

92959295
if ((conf->flags & GUC_NO_SHOW_ALL) ||
92969296
((conf->flags & GUC_SUPERUSER_ONLY) &&
9297-
!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_SETTINGS)))
9297+
!is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS)))
92989298
continue;
92999299

93009300
/* assign to the values array */
@@ -9361,7 +9361,7 @@ get_explain_guc_options(int *num)
93619361
/* return only options visible to the current user */
93629362
if ((conf->flags & GUC_NO_SHOW_ALL) ||
93639363
((conf->flags & GUC_SUPERUSER_ONLY) &&
9364-
!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_SETTINGS)))
9364+
!is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS)))
93659365
continue;
93669366

93679367
/* return only options that are different from their boot values */
@@ -9450,7 +9450,7 @@ GetConfigOptionByName(const char *name, const char **varname, bool missing_ok)
94509450
}
94519451

94529452
if ((record->flags & GUC_SUPERUSER_ONLY) &&
9453-
!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_SETTINGS))
9453+
!is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
94549454
ereport(ERROR,
94559455
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
94569456
errmsg("must be superuser or a member of pg_read_all_settings to examine \"%s\"",
@@ -9481,7 +9481,7 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
94819481
{
94829482
if ((conf->flags & GUC_NO_SHOW_ALL) ||
94839483
((conf->flags & GUC_SUPERUSER_ONLY) &&
9484-
!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_SETTINGS)))
9484+
!is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS)))
94859485
*noshow = true;
94869486
else
94879487
*noshow = false;
@@ -9676,7 +9676,7 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
96769676
* insufficiently-privileged users.
96779677
*/
96789678
if (conf->source == PGC_S_FILE &&
9679-
is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_SETTINGS))
9679+
is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
96809680
{
96819681
values[14] = conf->sourcefile;
96829682
snprintf(buffer, sizeof(buffer), "%d", conf->sourceline);

0 commit comments

Comments
 (0)