public inbox for [email protected]
help / color / mirror / Atom feedFrom: Nathan Bossart <[email protected]>
To: Robert Haas <[email protected]>
Cc: [email protected]
Subject: Re: improve predefined roles documentation
Date: Tue, 18 Jun 2024 11:52:12 -0500
Message-ID: <ZnG7PNN6BK32G_6B@nathan> (raw)
In-Reply-To: <CA+TgmoYhyieAwqvGYRTdz92ySFCScjsPLh_KySZohtWBfW-Usg@mail.gmail.com>
References: <ZmtM-4-eRtq8DRf6@nathan>
<CA+TgmoYhyieAwqvGYRTdz92ySFCScjsPLh_KySZohtWBfW-Usg@mail.gmail.com>
On Mon, Jun 17, 2024 at 02:10:22PM -0400, Robert Haas wrote:
> On Thu, Jun 13, 2024 at 3:48 PM Nathan Bossart <[email protected]> wrote:
>> I think we could improve matters by abandoning the table and instead
>> documenting these roles more like we document GUCs, i.e., each one has a
>> section below it where we can document it in as much detail as we want.
>> Some of these roles should probably be documented together (e.g.,
>> pg_read_all_data and pg_write_all_data), so the ordering is unlikely to be
>> perfect, but I'm hoping it would still be a net improvement.
>
> +1. I'm not sure about all of the details, but I like the general idea.
Here is a first try. I did pretty much exactly what I proposed in the
quoted text, so I don't have much else to say about it. I didn't see an
easy way to specify multiple ids and xreflabels for a given entry, so the
entries that describe multiple roles just use the name of the first role
listed. In practice, I think this just means you need to do a little extra
work when linking to one of the other roles from elsewhere in the docs,
which doesn't seem too terrible.
--
nathan
From 89db4a562ddb07aa1215608fb116b511143b0e66 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <[email protected]>
Date: Tue, 18 Jun 2024 11:38:40 -0500
Subject: [PATCH v1 1/1] revamp predefined roles documentation
---
doc/src/sgml/config.sgml | 2 +-
doc/src/sgml/monitoring.sgml | 4 +-
doc/src/sgml/ref/checkpoint.sgml | 2 +-
doc/src/sgml/ref/reindex.sgml | 2 +-
doc/src/sgml/user-manag.sgml | 339 ++++++++++++++++---------------
5 files changed, 185 insertions(+), 164 deletions(-)
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 698169afdb..b9fd3f3bd6 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -731,7 +731,7 @@ include_dir 'conf.d'
<para>
Determines the number of connection <quote>slots</quote> that are
reserved for connections by roles with privileges of the
- <link linkend="predefined-roles-table"><literal>pg_use_reserved_connections</literal></link>
+ <xref linkend="predefined-role-pg-use-reserved-connections"/>
role. Whenever the number of free connection slots is greater than
<xref linkend="guc-superuser-reserved-connections"/> but less than or
equal to the sum of <varname>superuser_reserved_connections</varname>
diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index b2ad9b446f..133ad462cb 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -286,8 +286,8 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
other sessions, many columns will be null. Note, however, that the
existence of a session and its general properties such as its sessions user
and database are visible to all users. Superusers and roles with privileges of
- built-in role <literal>pg_read_all_stats</literal> (see also <xref
- linkend="predefined-roles"/>) can see all the information about all sessions.
+ built-in role <link linkend="predefined-role-pg-read-all-settings"><literal>pg_read_all_stats</literal></link>
+ can see all the information about all sessions.
</para>
<table id="monitoring-stats-dynamic-views-table">
diff --git a/doc/src/sgml/ref/checkpoint.sgml b/doc/src/sgml/ref/checkpoint.sgml
index 28a1d717b8..db011a47d0 100644
--- a/doc/src/sgml/ref/checkpoint.sgml
+++ b/doc/src/sgml/ref/checkpoint.sgml
@@ -53,7 +53,7 @@ CHECKPOINT
<para>
Only superusers or users with the privileges of
- the <link linkend="predefined-roles-table"><literal>pg_checkpoint</literal></link>
+ the <xref linkend="predefined-role-pg-checkpoint"/>
role can call <command>CHECKPOINT</command>.
</para>
</refsect1>
diff --git a/doc/src/sgml/ref/reindex.sgml b/doc/src/sgml/ref/reindex.sgml
index 2942dccf1e..dcf70d14bc 100644
--- a/doc/src/sgml/ref/reindex.sgml
+++ b/doc/src/sgml/ref/reindex.sgml
@@ -305,7 +305,7 @@ REINDEX [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] { DA
partitioned table, such commands skip the privilege checks when processing
the individual partitions. Reindexing a schema or database requires being the
owner of that schema or database or having privileges of the
- <link linkend="predefined-roles-table"><literal>pg_maintain</literal></link>
+ <xref linkend="predefined-role-pg-maintain"/>
role. Note specifically that it's thus
possible for non-superusers to rebuild indexes of tables owned by
other users. However, as a special exception,
diff --git a/doc/src/sgml/user-manag.sgml b/doc/src/sgml/user-manag.sgml
index 07a16247d7..1d3805d303 100644
--- a/doc/src/sgml/user-manag.sgml
+++ b/doc/src/sgml/user-manag.sgml
@@ -590,101 +590,71 @@ DROP ROLE doomed_role;
and information. Administrators (including roles that have the
<literal>CREATEROLE</literal> privilege) can <command>GRANT</command> these
roles to users and/or other roles in their environment, providing those
- users with access to the specified capabilities and information.
+ users with access to the specified capabilities and information. For
+ example:
+
+<programlisting>
+GRANT pg_signal_backend TO admin_user;
+</programlisting>
</para>
+ <warning>
+ <para>
+ Care should be taken when granting these roles to ensure they are only used
+ where needed and with the understanding that these roles grant access to
+ privileged information.
+ </para>
+ </warning>
+
<para>
- The predefined roles are described in <xref linkend="predefined-roles-table"/>.
+ The predefined roles are described below.
Note that the specific permissions for each of the roles may change in
the future as additional capabilities are added. Administrators
should monitor the release notes for changes.
- </para>
- <table tocentry="1" id="predefined-roles-table">
- <title>Predefined Roles</title>
- <tgroup cols="2">
- <colspec colname="col1" colwidth="1*"/>
- <colspec colname="col2" colwidth="2*"/>
- <thead>
- <row>
- <entry>Role</entry>
- <entry>Allowed Access</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>pg_read_all_data</entry>
- <entry>Read all data (tables, views, sequences), as if having
- <command>SELECT</command> rights on those objects, and USAGE rights on
- all schemas, even without having it explicitly. This role does not have
- the role attribute <literal>BYPASSRLS</literal> set. If RLS is being
- used, an administrator may wish to set <literal>BYPASSRLS</literal> on
- roles which this role is GRANTed to.</entry>
- </row>
- <row>
- <entry>pg_write_all_data</entry>
- <entry>Write all data (tables, views, sequences), as if having
- <command>INSERT</command>, <command>UPDATE</command>, and
- <command>DELETE</command> rights on those objects, and USAGE rights on
- all schemas, even without having it explicitly. This role does not have
- the role attribute <literal>BYPASSRLS</literal> set. If RLS is being
- used, an administrator may wish to set <literal>BYPASSRLS</literal> on
- roles which this role is GRANTed to.</entry>
- </row>
- <row>
- <entry>pg_read_all_settings</entry>
- <entry>Read all configuration variables, even those normally visible only to
- superusers.</entry>
- </row>
- <row>
- <entry>pg_read_all_stats</entry>
- <entry>Read all pg_stat_* views and use various statistics related extensions,
- even those normally visible only to superusers.</entry>
- </row>
- <row>
- <entry>pg_stat_scan_tables</entry>
- <entry>Execute monitoring functions that may take <literal>ACCESS SHARE</literal> locks on tables,
- potentially for a long time.</entry>
- </row>
- <row>
- <entry>pg_monitor</entry>
- <entry>Read/execute various monitoring views and functions.
- This role is a member of <literal>pg_read_all_settings</literal>,
- <literal>pg_read_all_stats</literal> and
- <literal>pg_stat_scan_tables</literal>.</entry>
- </row>
- <row>
- <entry>pg_database_owner</entry>
- <entry>None. Membership consists, implicitly, of the current database owner.</entry>
- </row>
- <row>
- <entry>pg_signal_backend</entry>
- <entry>Signal another backend to cancel a query or terminate its session.</entry>
- </row>
- <row>
- <entry>pg_read_server_files</entry>
- <entry>Allow reading files from any location the database can access on the server with COPY and
- other file-access functions.</entry>
- </row>
- <row>
- <entry>pg_write_server_files</entry>
- <entry>Allow writing to files in any location the database can access on the server with COPY and
- other file-access functions.</entry>
- </row>
- <row>
- <entry>pg_execute_server_program</entry>
- <entry>Allow executing programs on the database server as the user the database runs as with
- COPY and other functions which allow executing a server-side program.</entry>
- </row>
- <row>
- <entry>pg_checkpoint</entry>
- <entry>Allow executing
- the <link linkend="sql-checkpoint"><command>CHECKPOINT</command></link>
- command.</entry>
- </row>
- <row>
- <entry>pg_maintain</entry>
- <entry>Allow executing
+ <variablelist>
+ <varlistentry id="predefined-role-pg-checkpoint" xreflabel="pg_checkpoint">
+ <term><varname>pg_checkpoint</varname></term>
+ <listitem>
+ <para>
+ Allows executing the
+ <link linkend="sql-checkpoint"><command>CHECKPOINT</command></link> command.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-create-subscription" xreflabel="pg_create_subscription">
+ <term><varname>pg_create_subscription</varname></term>
+ <listitem>
+ <para>
+ Allows users with <literal>CREATE</literal> permission on the database to issue
+ <link linkend="sql-createsubscription"><command>CREATE SUBSCRIPTION</command></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-database-owner" xreflabel="pg_database_owner">
+ <term><varname>pg_database_owner</varname></term>
+ <listitem>
+ <para>
+ Membership consists, implicitly, of the current database owner. Like
+ any role, it can own objects or receive grants of access privileges.
+ Consequently, once <literal>pg_database_owner</literal> has rights
+ within a template database, each owner of a database instantiated from
+ that template will exercise those rights.
+ <literal>pg_database_owner</literal> cannot be a member of any role, and
+ it cannot have non-implicit members. Initially, this role owns the
+ <literal>public</literal> schema, so each database owner governs local
+ use of the schema.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-maintain" xreflabel="pg_maintain">
+ <term><varname>pg_maintain</varname></term>
+ <listitem>
+ <para>
+ Allows executing
<link linkend="sql-vacuum"><command>VACUUM</command></link>,
<link linkend="sql-analyze"><command>ANALYZE</command></link>,
<link linkend="sql-cluster"><command>CLUSTER</command></link>,
@@ -692,78 +662,129 @@ DROP ROLE doomed_role;
<link linkend="sql-reindex"><command>REINDEX</command></link>,
and <link linkend="sql-lock"><command>LOCK TABLE</command></link> on all
relations, as if having <literal>MAINTAIN</literal> rights on those
- objects, even without having it explicitly.</entry>
- </row>
- <row>
- <entry>pg_use_reserved_connections</entry>
- <entry>Allow use of connection slots reserved via
- <xref linkend="guc-reserved-connections"/>.</entry>
- </row>
- <row>
- <entry>pg_create_subscription</entry>
- <entry>Allow users with <literal>CREATE</literal> permission on the
- database to issue
- <link linkend="sql-createsubscription"><command>CREATE SUBSCRIPTION</command></link>.</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>
- The <literal>pg_monitor</literal>, <literal>pg_read_all_settings</literal>,
- <literal>pg_read_all_stats</literal> and <literal>pg_stat_scan_tables</literal>
- roles are intended to allow administrators to easily configure a role for the
- purpose of monitoring the database server. They grant a set of common privileges
- allowing the role to read various useful configuration settings, statistics and
- other system information normally restricted to superusers.
- </para>
-
- <para>
- The <literal>pg_database_owner</literal> role has one implicit,
- situation-dependent member, namely the owner of the current database. Like
- any role, it can own objects or receive grants of access privileges.
- Consequently, once <literal>pg_database_owner</literal> has rights within a
- template database, each owner of a database instantiated from that template
- will exercise those rights. <literal>pg_database_owner</literal> cannot be
- a member of any role, and it cannot have non-implicit members. Initially,
- this role owns the <literal>public</literal> schema, so each database owner
- governs local use of the schema.
- </para>
-
- <para>
- The <literal>pg_signal_backend</literal> role is intended to allow
- administrators to enable trusted, but non-superuser, roles to send signals
- to other backends. Currently this role enables sending of signals for
- canceling a query on another backend or terminating its session. A user
- granted this role cannot however send signals to a backend owned by a
- superuser. See <xref linkend="functions-admin-signal"/>.
- </para>
-
- <para>
- The <literal>pg_read_server_files</literal>, <literal>pg_write_server_files</literal> and
- <literal>pg_execute_server_program</literal> roles are intended to allow administrators to have
- trusted, but non-superuser, roles which are able to access files and run programs on the
- database server as the user the database runs as. As these roles are able to access any file on
- the server file system, they bypass all database-level permission checks when accessing files
- directly and they could be used to gain superuser-level access, therefore
- great care should be taken when granting these roles to users.
- </para>
-
- <para>
- Care should be taken when granting these roles to ensure they are only used where
- needed and with the understanding that these roles grant access to privileged
- information.
- </para>
-
- <para>
- Administrators can grant access to these roles to users using the
- <link linkend="sql-grant"><command>GRANT</command></link> command, for example:
-
-<programlisting>
-GRANT pg_signal_backend TO admin_user;
-</programlisting>
+ objects, even without having it explicitly.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-read-all-data" xreflabel="pg_read_all_data">
+ <term><varname>pg_read_all_data</varname></term>
+ <term><varname>pg_write_all_data</varname></term>
+ <listitem>
+ <para>
+ <literal>pg_read_all_data</literal> allows reading all data (tables,
+ views, sequences), as if having <command>SELECT</command> rights on
+ those objects, and USAGE rights on all schemas, even without having it
+ explicitly. This role does not have the role attribute
+ <literal>BYPASSRLS</literal> set. If RLS is being used, an
+ administrator may wish to set <literal>BYPASSRLS</literal> on roles
+ which this role is GRANTed to.
+ </para>
+ <para>
+ <literal>pg_write_all_data</literal> allows writing all data (tables,
+ views, sequences), as if having <command>INSERT</command>,
+ <command>UPDATE</command>, and <command>DELETE</command> rights on those
+ objects, and USAGE rights on all schemas, even without having it
+ explicitly. This role does not have the role attribute
+ <literal>BYPASSRLS</literal> set. If RLS is being used, an
+ administrator may wish to set <literal>BYPASSRLS</literal> on roles
+ which this role is GRANTed to.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-read-all-settings" xreflabel="pg_read_all_settings">
+ <term><varname>pg_read_all_settings</varname></term>
+ <term><varname>pg_read_all_stats</varname></term>
+ <term><varname>pg_stat_scan_tables</varname></term>
+ <term><varname>pg_monitor</varname></term>
+ <listitem>
+ <para>
+ These roles are intended to allow administrators to easily configure a
+ role for the purpose of monitoring the database server. They grant a
+ set of common privileges allowing the role to read various useful
+ configuration settings, statistics, and other system information
+ normally restricted to superusers.
+ </para>
+ <para>
+ <literal>pg_read_all_settings</literal> allows reading all configuration
+ variables, even those normally visible only to superusers.
+ </para>
+ <para>
+ <literal>pg_read_all_stats</literal> allows reading all pg_stat_* views
+ and use various statistics related extensions, even those normally
+ visible only to superusers.
+ </para>
+ <para>
+ <literal>pg_stat_scan_tables</literal> allows executing monitoring
+ functions that may take <literal>ACCESS SHARE</literal> locks on tables,
+ potentially for a long time.
+ </para>
+ <para>
+ <literal>pg_monitor</literal> allows reading/executing various
+ monitoring views and functions. This role is a member of
+ <literal>pg_read_all_settings</literal>,
+ <literal>pg_read_all_stats</literal> and
+ <literal>pg_stat_scan_tables</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-read-server-files" xreflabel="pg_read_server_files">
+ <term><varname>pg_read_server_files</varname></term>
+ <term><varname>pg_write_server_files</varname></term>
+ <term><varname>pg_execute_server_program</varname></term>
+ <listitem>
+ <para>
+ These roles are intended to allow administrators to have trusted, but
+ non-superuser, roles which are able to access files and run programs on
+ the database server as the user the database runs as. As these roles
+ are able to access any file on the server file system, they bypass all
+ database-level permission checks when accessing files directly and they
+ could be used to gain superuser-level access, therefore great care
+ should be taken when granting these roles to users.
+ </para>
+ <para>
+ <literal>pg_read_server_files</literal> allows reading files from any
+ location the database can access on the server with COPY and other
+ file-access functions.
+ </para>
+ <para>
+ <literal>pg_write_server_files</literal> allows writing to files in any
+ location the database can access on the server with COPY any other
+ file-access functions.
+ </para>
+ <para>
+ <literal>pg_execute_server_program</literal> allows executing programs
+ on the database server as the user the database runs as with COPY and
+ other functions which allow executing a server-side program.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-signal-backend" xreflabel="pg_signal_backend">
+ <term><varname>pg_signal_backend</varname></term>
+ <listitem>
+ <para>
+ Allows signaling another backend to cancel a query or terminate its
+ session. A user granted this role cannot however send signals to a
+ backend owned by a superuser. See
+ <xref linkend="functions-admin-signal"/>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-use-reserved-connections" xreflabel="pg_use_reserved_connections">
+ <term><varname>pg_use_reserved_connections</varname></term>
+ <listitem>
+ <para>
+ Allows use of connection slots reserved via
+ <xref linkend="guc-reserved-connections"/>.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</para>
-
</sect1>
<sect1 id="perm-functions">
--
2.39.3 (Apple Git-146)
Attachments:
[text/plain] v1-0001-revamp-predefined-roles-documentation.patch (19.2K, ../ZnG7PNN6BK32G_6B@nathan/2-v1-0001-revamp-predefined-roles-documentation.patch)
download | inline diff:
From 89db4a562ddb07aa1215608fb116b511143b0e66 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <[email protected]>
Date: Tue, 18 Jun 2024 11:38:40 -0500
Subject: [PATCH v1 1/1] revamp predefined roles documentation
---
doc/src/sgml/config.sgml | 2 +-
doc/src/sgml/monitoring.sgml | 4 +-
doc/src/sgml/ref/checkpoint.sgml | 2 +-
doc/src/sgml/ref/reindex.sgml | 2 +-
doc/src/sgml/user-manag.sgml | 339 ++++++++++++++++---------------
5 files changed, 185 insertions(+), 164 deletions(-)
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 698169afdb..b9fd3f3bd6 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -731,7 +731,7 @@ include_dir 'conf.d'
<para>
Determines the number of connection <quote>slots</quote> that are
reserved for connections by roles with privileges of the
- <link linkend="predefined-roles-table"><literal>pg_use_reserved_connections</literal></link>
+ <xref linkend="predefined-role-pg-use-reserved-connections"/>
role. Whenever the number of free connection slots is greater than
<xref linkend="guc-superuser-reserved-connections"/> but less than or
equal to the sum of <varname>superuser_reserved_connections</varname>
diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index b2ad9b446f..133ad462cb 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -286,8 +286,8 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
other sessions, many columns will be null. Note, however, that the
existence of a session and its general properties such as its sessions user
and database are visible to all users. Superusers and roles with privileges of
- built-in role <literal>pg_read_all_stats</literal> (see also <xref
- linkend="predefined-roles"/>) can see all the information about all sessions.
+ built-in role <link linkend="predefined-role-pg-read-all-settings"><literal>pg_read_all_stats</literal></link>
+ can see all the information about all sessions.
</para>
<table id="monitoring-stats-dynamic-views-table">
diff --git a/doc/src/sgml/ref/checkpoint.sgml b/doc/src/sgml/ref/checkpoint.sgml
index 28a1d717b8..db011a47d0 100644
--- a/doc/src/sgml/ref/checkpoint.sgml
+++ b/doc/src/sgml/ref/checkpoint.sgml
@@ -53,7 +53,7 @@ CHECKPOINT
<para>
Only superusers or users with the privileges of
- the <link linkend="predefined-roles-table"><literal>pg_checkpoint</literal></link>
+ the <xref linkend="predefined-role-pg-checkpoint"/>
role can call <command>CHECKPOINT</command>.
</para>
</refsect1>
diff --git a/doc/src/sgml/ref/reindex.sgml b/doc/src/sgml/ref/reindex.sgml
index 2942dccf1e..dcf70d14bc 100644
--- a/doc/src/sgml/ref/reindex.sgml
+++ b/doc/src/sgml/ref/reindex.sgml
@@ -305,7 +305,7 @@ REINDEX [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] { DA
partitioned table, such commands skip the privilege checks when processing
the individual partitions. Reindexing a schema or database requires being the
owner of that schema or database or having privileges of the
- <link linkend="predefined-roles-table"><literal>pg_maintain</literal></link>
+ <xref linkend="predefined-role-pg-maintain"/>
role. Note specifically that it's thus
possible for non-superusers to rebuild indexes of tables owned by
other users. However, as a special exception,
diff --git a/doc/src/sgml/user-manag.sgml b/doc/src/sgml/user-manag.sgml
index 07a16247d7..1d3805d303 100644
--- a/doc/src/sgml/user-manag.sgml
+++ b/doc/src/sgml/user-manag.sgml
@@ -590,101 +590,71 @@ DROP ROLE doomed_role;
and information. Administrators (including roles that have the
<literal>CREATEROLE</literal> privilege) can <command>GRANT</command> these
roles to users and/or other roles in their environment, providing those
- users with access to the specified capabilities and information.
+ users with access to the specified capabilities and information. For
+ example:
+
+<programlisting>
+GRANT pg_signal_backend TO admin_user;
+</programlisting>
</para>
+ <warning>
+ <para>
+ Care should be taken when granting these roles to ensure they are only used
+ where needed and with the understanding that these roles grant access to
+ privileged information.
+ </para>
+ </warning>
+
<para>
- The predefined roles are described in <xref linkend="predefined-roles-table"/>.
+ The predefined roles are described below.
Note that the specific permissions for each of the roles may change in
the future as additional capabilities are added. Administrators
should monitor the release notes for changes.
- </para>
- <table tocentry="1" id="predefined-roles-table">
- <title>Predefined Roles</title>
- <tgroup cols="2">
- <colspec colname="col1" colwidth="1*"/>
- <colspec colname="col2" colwidth="2*"/>
- <thead>
- <row>
- <entry>Role</entry>
- <entry>Allowed Access</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>pg_read_all_data</entry>
- <entry>Read all data (tables, views, sequences), as if having
- <command>SELECT</command> rights on those objects, and USAGE rights on
- all schemas, even without having it explicitly. This role does not have
- the role attribute <literal>BYPASSRLS</literal> set. If RLS is being
- used, an administrator may wish to set <literal>BYPASSRLS</literal> on
- roles which this role is GRANTed to.</entry>
- </row>
- <row>
- <entry>pg_write_all_data</entry>
- <entry>Write all data (tables, views, sequences), as if having
- <command>INSERT</command>, <command>UPDATE</command>, and
- <command>DELETE</command> rights on those objects, and USAGE rights on
- all schemas, even without having it explicitly. This role does not have
- the role attribute <literal>BYPASSRLS</literal> set. If RLS is being
- used, an administrator may wish to set <literal>BYPASSRLS</literal> on
- roles which this role is GRANTed to.</entry>
- </row>
- <row>
- <entry>pg_read_all_settings</entry>
- <entry>Read all configuration variables, even those normally visible only to
- superusers.</entry>
- </row>
- <row>
- <entry>pg_read_all_stats</entry>
- <entry>Read all pg_stat_* views and use various statistics related extensions,
- even those normally visible only to superusers.</entry>
- </row>
- <row>
- <entry>pg_stat_scan_tables</entry>
- <entry>Execute monitoring functions that may take <literal>ACCESS SHARE</literal> locks on tables,
- potentially for a long time.</entry>
- </row>
- <row>
- <entry>pg_monitor</entry>
- <entry>Read/execute various monitoring views and functions.
- This role is a member of <literal>pg_read_all_settings</literal>,
- <literal>pg_read_all_stats</literal> and
- <literal>pg_stat_scan_tables</literal>.</entry>
- </row>
- <row>
- <entry>pg_database_owner</entry>
- <entry>None. Membership consists, implicitly, of the current database owner.</entry>
- </row>
- <row>
- <entry>pg_signal_backend</entry>
- <entry>Signal another backend to cancel a query or terminate its session.</entry>
- </row>
- <row>
- <entry>pg_read_server_files</entry>
- <entry>Allow reading files from any location the database can access on the server with COPY and
- other file-access functions.</entry>
- </row>
- <row>
- <entry>pg_write_server_files</entry>
- <entry>Allow writing to files in any location the database can access on the server with COPY and
- other file-access functions.</entry>
- </row>
- <row>
- <entry>pg_execute_server_program</entry>
- <entry>Allow executing programs on the database server as the user the database runs as with
- COPY and other functions which allow executing a server-side program.</entry>
- </row>
- <row>
- <entry>pg_checkpoint</entry>
- <entry>Allow executing
- the <link linkend="sql-checkpoint"><command>CHECKPOINT</command></link>
- command.</entry>
- </row>
- <row>
- <entry>pg_maintain</entry>
- <entry>Allow executing
+ <variablelist>
+ <varlistentry id="predefined-role-pg-checkpoint" xreflabel="pg_checkpoint">
+ <term><varname>pg_checkpoint</varname></term>
+ <listitem>
+ <para>
+ Allows executing the
+ <link linkend="sql-checkpoint"><command>CHECKPOINT</command></link> command.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-create-subscription" xreflabel="pg_create_subscription">
+ <term><varname>pg_create_subscription</varname></term>
+ <listitem>
+ <para>
+ Allows users with <literal>CREATE</literal> permission on the database to issue
+ <link linkend="sql-createsubscription"><command>CREATE SUBSCRIPTION</command></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-database-owner" xreflabel="pg_database_owner">
+ <term><varname>pg_database_owner</varname></term>
+ <listitem>
+ <para>
+ Membership consists, implicitly, of the current database owner. Like
+ any role, it can own objects or receive grants of access privileges.
+ Consequently, once <literal>pg_database_owner</literal> has rights
+ within a template database, each owner of a database instantiated from
+ that template will exercise those rights.
+ <literal>pg_database_owner</literal> cannot be a member of any role, and
+ it cannot have non-implicit members. Initially, this role owns the
+ <literal>public</literal> schema, so each database owner governs local
+ use of the schema.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-maintain" xreflabel="pg_maintain">
+ <term><varname>pg_maintain</varname></term>
+ <listitem>
+ <para>
+ Allows executing
<link linkend="sql-vacuum"><command>VACUUM</command></link>,
<link linkend="sql-analyze"><command>ANALYZE</command></link>,
<link linkend="sql-cluster"><command>CLUSTER</command></link>,
@@ -692,78 +662,129 @@ DROP ROLE doomed_role;
<link linkend="sql-reindex"><command>REINDEX</command></link>,
and <link linkend="sql-lock"><command>LOCK TABLE</command></link> on all
relations, as if having <literal>MAINTAIN</literal> rights on those
- objects, even without having it explicitly.</entry>
- </row>
- <row>
- <entry>pg_use_reserved_connections</entry>
- <entry>Allow use of connection slots reserved via
- <xref linkend="guc-reserved-connections"/>.</entry>
- </row>
- <row>
- <entry>pg_create_subscription</entry>
- <entry>Allow users with <literal>CREATE</literal> permission on the
- database to issue
- <link linkend="sql-createsubscription"><command>CREATE SUBSCRIPTION</command></link>.</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>
- The <literal>pg_monitor</literal>, <literal>pg_read_all_settings</literal>,
- <literal>pg_read_all_stats</literal> and <literal>pg_stat_scan_tables</literal>
- roles are intended to allow administrators to easily configure a role for the
- purpose of monitoring the database server. They grant a set of common privileges
- allowing the role to read various useful configuration settings, statistics and
- other system information normally restricted to superusers.
- </para>
-
- <para>
- The <literal>pg_database_owner</literal> role has one implicit,
- situation-dependent member, namely the owner of the current database. Like
- any role, it can own objects or receive grants of access privileges.
- Consequently, once <literal>pg_database_owner</literal> has rights within a
- template database, each owner of a database instantiated from that template
- will exercise those rights. <literal>pg_database_owner</literal> cannot be
- a member of any role, and it cannot have non-implicit members. Initially,
- this role owns the <literal>public</literal> schema, so each database owner
- governs local use of the schema.
- </para>
-
- <para>
- The <literal>pg_signal_backend</literal> role is intended to allow
- administrators to enable trusted, but non-superuser, roles to send signals
- to other backends. Currently this role enables sending of signals for
- canceling a query on another backend or terminating its session. A user
- granted this role cannot however send signals to a backend owned by a
- superuser. See <xref linkend="functions-admin-signal"/>.
- </para>
-
- <para>
- The <literal>pg_read_server_files</literal>, <literal>pg_write_server_files</literal> and
- <literal>pg_execute_server_program</literal> roles are intended to allow administrators to have
- trusted, but non-superuser, roles which are able to access files and run programs on the
- database server as the user the database runs as. As these roles are able to access any file on
- the server file system, they bypass all database-level permission checks when accessing files
- directly and they could be used to gain superuser-level access, therefore
- great care should be taken when granting these roles to users.
- </para>
-
- <para>
- Care should be taken when granting these roles to ensure they are only used where
- needed and with the understanding that these roles grant access to privileged
- information.
- </para>
-
- <para>
- Administrators can grant access to these roles to users using the
- <link linkend="sql-grant"><command>GRANT</command></link> command, for example:
-
-<programlisting>
-GRANT pg_signal_backend TO admin_user;
-</programlisting>
+ objects, even without having it explicitly.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-read-all-data" xreflabel="pg_read_all_data">
+ <term><varname>pg_read_all_data</varname></term>
+ <term><varname>pg_write_all_data</varname></term>
+ <listitem>
+ <para>
+ <literal>pg_read_all_data</literal> allows reading all data (tables,
+ views, sequences), as if having <command>SELECT</command> rights on
+ those objects, and USAGE rights on all schemas, even without having it
+ explicitly. This role does not have the role attribute
+ <literal>BYPASSRLS</literal> set. If RLS is being used, an
+ administrator may wish to set <literal>BYPASSRLS</literal> on roles
+ which this role is GRANTed to.
+ </para>
+ <para>
+ <literal>pg_write_all_data</literal> allows writing all data (tables,
+ views, sequences), as if having <command>INSERT</command>,
+ <command>UPDATE</command>, and <command>DELETE</command> rights on those
+ objects, and USAGE rights on all schemas, even without having it
+ explicitly. This role does not have the role attribute
+ <literal>BYPASSRLS</literal> set. If RLS is being used, an
+ administrator may wish to set <literal>BYPASSRLS</literal> on roles
+ which this role is GRANTed to.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-read-all-settings" xreflabel="pg_read_all_settings">
+ <term><varname>pg_read_all_settings</varname></term>
+ <term><varname>pg_read_all_stats</varname></term>
+ <term><varname>pg_stat_scan_tables</varname></term>
+ <term><varname>pg_monitor</varname></term>
+ <listitem>
+ <para>
+ These roles are intended to allow administrators to easily configure a
+ role for the purpose of monitoring the database server. They grant a
+ set of common privileges allowing the role to read various useful
+ configuration settings, statistics, and other system information
+ normally restricted to superusers.
+ </para>
+ <para>
+ <literal>pg_read_all_settings</literal> allows reading all configuration
+ variables, even those normally visible only to superusers.
+ </para>
+ <para>
+ <literal>pg_read_all_stats</literal> allows reading all pg_stat_* views
+ and use various statistics related extensions, even those normally
+ visible only to superusers.
+ </para>
+ <para>
+ <literal>pg_stat_scan_tables</literal> allows executing monitoring
+ functions that may take <literal>ACCESS SHARE</literal> locks on tables,
+ potentially for a long time.
+ </para>
+ <para>
+ <literal>pg_monitor</literal> allows reading/executing various
+ monitoring views and functions. This role is a member of
+ <literal>pg_read_all_settings</literal>,
+ <literal>pg_read_all_stats</literal> and
+ <literal>pg_stat_scan_tables</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-read-server-files" xreflabel="pg_read_server_files">
+ <term><varname>pg_read_server_files</varname></term>
+ <term><varname>pg_write_server_files</varname></term>
+ <term><varname>pg_execute_server_program</varname></term>
+ <listitem>
+ <para>
+ These roles are intended to allow administrators to have trusted, but
+ non-superuser, roles which are able to access files and run programs on
+ the database server as the user the database runs as. As these roles
+ are able to access any file on the server file system, they bypass all
+ database-level permission checks when accessing files directly and they
+ could be used to gain superuser-level access, therefore great care
+ should be taken when granting these roles to users.
+ </para>
+ <para>
+ <literal>pg_read_server_files</literal> allows reading files from any
+ location the database can access on the server with COPY and other
+ file-access functions.
+ </para>
+ <para>
+ <literal>pg_write_server_files</literal> allows writing to files in any
+ location the database can access on the server with COPY any other
+ file-access functions.
+ </para>
+ <para>
+ <literal>pg_execute_server_program</literal> allows executing programs
+ on the database server as the user the database runs as with COPY and
+ other functions which allow executing a server-side program.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-signal-backend" xreflabel="pg_signal_backend">
+ <term><varname>pg_signal_backend</varname></term>
+ <listitem>
+ <para>
+ Allows signaling another backend to cancel a query or terminate its
+ session. A user granted this role cannot however send signals to a
+ backend owned by a superuser. See
+ <xref linkend="functions-admin-signal"/>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="predefined-role-pg-use-reserved-connections" xreflabel="pg_use_reserved_connections">
+ <term><varname>pg_use_reserved_connections</varname></term>
+ <listitem>
+ <para>
+ Allows use of connection slots reserved via
+ <xref linkend="guc-reserved-connections"/>.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</para>
-
</sect1>
<sect1 id="perm-functions">
--
2.39.3 (Apple Git-146)
[text/html] predefined-roles.html (11.7K, ../ZnG7PNN6BK32G_6B@nathan/3-predefined-roles.html)
download | inline:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>21.5. Predefined Roles</title><link rel="stylesheet" type="text/css" href="https://www.postgresql.org/media/css/docs-complete.css" /><link rev="made" href="[email protected]" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="role-removal.html" title="21.4. Dropping Roles" /><link rel="next" href="perm-functions.html" title="21.6. Function Security" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">21.5. Predefined Roles</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="role-removal.html" title="21.4. Dropping Roles">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="user-manag.html" title="Chapter 21. Database Roles">Up</a></td><th width="60%" align="center">Chapter 21. Database Roles</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 17beta1 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="perm-functions.html" title="21.6. Function Security">Next</a></td></tr></table><hr /></div><div class="sect1" id="PREDEFINED-ROLES"><div class="titlepage"><div><div><h2 class="title" style="clear: both">21.5. Predefined Roles <a href="#PREDEFINED-ROLES" class="id_link">#</a></h2></div></div></div><a id="id-1.6.8.9.2" class="indexterm"></a><p>
<span class="productname">PostgreSQL</span> provides a set of predefined roles
that provide access to certain, commonly needed, privileged capabilities
and information. Administrators (including roles that have the
<code class="literal">CREATEROLE</code> privilege) can <code class="command">GRANT</code> these
roles to users and/or other roles in their environment, providing those
users with access to the specified capabilities and information. For
example:
</p><pre class="programlisting">
GRANT pg_signal_backend TO admin_user;
</pre><p>
</p><div class="warning"><h3 class="title">Warning</h3><p>
Care should be taken when granting these roles to ensure they are only used
where needed and with the understanding that these roles grant access to
privileged information.
</p></div><p>
The predefined roles are described below.
Note that the specific permissions for each of the roles may change in
the future as additional capabilities are added. Administrators
should monitor the release notes for changes.
</p><div class="variablelist"><dl class="variablelist"><dt id="PREDEFINED-ROLE-PG-CHECKPOINT"><span class="term"><code class="varname">pg_checkpoint</code></span> <a href="#PREDEFINED-ROLE-PG-CHECKPOINT" class="id_link">#</a></dt><dd><p>
Allows executing the
<a class="link" href="sql-checkpoint.html" title="CHECKPOINT"><code class="command">CHECKPOINT</code></a> command.
</p></dd><dt id="PREDEFINED-ROLE-PG-CREATE-SUBSCRIPTION"><span class="term"><code class="varname">pg_create_subscription</code></span> <a href="#PREDEFINED-ROLE-PG-CREATE-SUBSCRIPTION" class="id_link">#</a></dt><dd><p>
Allows users with <code class="literal">CREATE</code> permission on the database to issue
<a class="link" href="sql-createsubscription.html" title="CREATE SUBSCRIPTION"><code class="command">CREATE SUBSCRIPTION</code></a>.
</p></dd><dt id="PREDEFINED-ROLE-PG-DATABASE-OWNER"><span class="term"><code class="varname">pg_database_owner</code></span> <a href="#PREDEFINED-ROLE-PG-DATABASE-OWNER" class="id_link">#</a></dt><dd><p>
Membership consists, implicitly, of the current database owner. Like
any role, it can own objects or receive grants of access privileges.
Consequently, once <code class="literal">pg_database_owner</code> has rights
within a template database, each owner of a database instantiated from
that template will exercise those rights.
<code class="literal">pg_database_owner</code> cannot be a member of any role, and
it cannot have non-implicit members. Initially, this role owns the
<code class="literal">public</code> schema, so each database owner governs local
use of the schema.
</p></dd><dt id="PREDEFINED-ROLE-PG-MAINTAIN"><span class="term"><code class="varname">pg_maintain</code></span> <a href="#PREDEFINED-ROLE-PG-MAINTAIN" class="id_link">#</a></dt><dd><p>
Allows executing
<a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a>,
<a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>,
<a class="link" href="sql-cluster.html" title="CLUSTER"><code class="command">CLUSTER</code></a>,
<a class="link" href="sql-refreshmaterializedview.html" title="REFRESH MATERIALIZED VIEW"><code class="command">REFRESH MATERIALIZED VIEW</code></a>,
<a class="link" href="sql-reindex.html" title="REINDEX"><code class="command">REINDEX</code></a>,
and <a class="link" href="sql-lock.html" title="LOCK"><code class="command">LOCK TABLE</code></a> on all
relations, as if having <code class="literal">MAINTAIN</code> rights on those
objects, even without having it explicitly.
</p></dd><dt id="PREDEFINED-ROLE-PG-READ-ALL-DATA"><span class="term"><code class="varname">pg_read_all_data</code><br /></span><span class="term"><code class="varname">pg_write_all_data</code></span> <a href="#PREDEFINED-ROLE-PG-READ-ALL-DATA" class="id_link">#</a></dt><dd><p>
<code class="literal">pg_read_all_data</code> allows reading all data (tables,
views, sequences), as if having <code class="command">SELECT</code> rights on
those objects, and USAGE rights on all schemas, even without having it
explicitly. This role does not have the role attribute
<code class="literal">BYPASSRLS</code> set. If RLS is being used, an
administrator may wish to set <code class="literal">BYPASSRLS</code> on roles
which this role is GRANTed to.
</p><p>
<code class="literal">pg_write_all_data</code> allows writing all data (tables,
views, sequences), as if having <code class="command">INSERT</code>,
<code class="command">UPDATE</code>, and <code class="command">DELETE</code> rights on those
objects, and USAGE rights on all schemas, even without having it
explicitly. This role does not have the role attribute
<code class="literal">BYPASSRLS</code> set. If RLS is being used, an
administrator may wish to set <code class="literal">BYPASSRLS</code> on roles
which this role is GRANTed to.
</p></dd><dt id="PREDEFINED-ROLE-PG-READ-ALL-SETTINGS"><span class="term"><code class="varname">pg_read_all_settings</code><br /></span><span class="term"><code class="varname">pg_read_all_stats</code><br /></span><span class="term"><code class="varname">pg_stat_scan_tables</code><br /></span><span class="term"><code class="varname">pg_monitor</code></span> <a href="#PREDEFINED-ROLE-PG-READ-ALL-SETTINGS" class="id_link">#</a></dt><dd><p>
These roles are intended to allow administrators to easily configure a
role for the purpose of monitoring the database server. They grant a
set of common privileges allowing the role to read various useful
configuration settings, statistics, and other system information
normally restricted to superusers.
</p><p>
<code class="literal">pg_read_all_settings</code> allows reading all configuration
variables, even those normally visible only to superusers.
</p><p>
<code class="literal">pg_read_all_stats</code> allows reading all pg_stat_* views
and use various statistics related extensions, even those normally
visible only to superusers.
</p><p>
<code class="literal">pg_stat_scan_tables</code> allows executing monitoring
functions that may take <code class="literal">ACCESS SHARE</code> locks on tables,
potentially for a long time.
</p><p>
<code class="literal">pg_monitor</code> allows reading/executing various
monitoring views and functions. This role is a member of
<code class="literal">pg_read_all_settings</code>,
<code class="literal">pg_read_all_stats</code> and
<code class="literal">pg_stat_scan_tables</code>.
</p></dd><dt id="PREDEFINED-ROLE-PG-READ-SERVER-FILES"><span class="term"><code class="varname">pg_read_server_files</code><br /></span><span class="term"><code class="varname">pg_write_server_files</code><br /></span><span class="term"><code class="varname">pg_execute_server_program</code></span> <a href="#PREDEFINED-ROLE-PG-READ-SERVER-FILES" class="id_link">#</a></dt><dd><p>
These roles are intended to allow administrators to have trusted, but
non-superuser, roles which are able to access files and run programs on
the database server as the user the database runs as. As these roles
are able to access any file on the server file system, they bypass all
database-level permission checks when accessing files directly and they
could be used to gain superuser-level access, therefore great care
should be taken when granting these roles to users.
</p><p>
<code class="literal">pg_read_server_files</code> allows reading files from any
location the database can access on the server with COPY and other
file-access functions.
</p><p>
<code class="literal">pg_write_server_files</code> allows writing to files in any
location the database can access on the server with COPY any other
file-access functions.
</p><p>
<code class="literal">pg_execute_server_program</code> allows executing programs
on the database server as the user the database runs as with COPY and
other functions which allow executing a server-side program.
</p></dd><dt id="PREDEFINED-ROLE-PG-SIGNAL-BACKEND"><span class="term"><code class="varname">pg_signal_backend</code></span> <a href="#PREDEFINED-ROLE-PG-SIGNAL-BACKEND" class="id_link">#</a></dt><dd><p>
Allows signaling another backend to cancel a query or terminate its
session. A user granted this role cannot however send signals to a
backend owned by a superuser. See
<a class="xref" href="functions-admin.html#FUNCTIONS-ADMIN-SIGNAL" title="9.28.2. Server Signaling Functions">Section 9.28.2</a>.
</p></dd><dt id="PREDEFINED-ROLE-PG-USE-RESERVED-CONNECTIONS"><span class="term"><code class="varname">pg_use_reserved_connections</code></span> <a href="#PREDEFINED-ROLE-PG-USE-RESERVED-CONNECTIONS" class="id_link">#</a></dt><dd><p>
Allows use of connection slots reserved via
<a class="xref" href="runtime-config-connection.html#GUC-RESERVED-CONNECTIONS">reserved_connections</a>.
</p></dd></dl></div><p>
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="role-removal.html" title="21.4. Dropping Roles">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="user-manag.html" title="Chapter 21. Database Roles">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="perm-functions.html" title="21.6. Function Security">Next</a></td></tr><tr><td width="40%" align="left" valign="top">21.4. Dropping Roles </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 17beta1 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 21.6. Function Security</td></tr></table></div></body></html>
view thread (9+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: improve predefined roles documentation
In-Reply-To: <ZnG7PNN6BK32G_6B@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox