pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Allow GRANT on pg_log_backend_memory_contexts().
8+ messages / 5 participants
[nested] [flat]
* pgsql: Allow GRANT on pg_log_backend_memory_contexts().
@ 2021-10-26 20:41 Jeff Davis <jdavis@postgresql.org>
2021-10-27 04:15 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 8+ messages in thread
From: Jeff Davis @ 2021-10-26 20:41 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Allow GRANT on pg_log_backend_memory_contexts().
Remove superuser check, allowing any user granted permissions on
pg_log_backend_memory_contexts() to log the memory contexts of any
backend.
Note that this could allow a privileged non-superuser to log the
memory contexts of a superuser backend, but as discussed, that does
not seem to be a problem.
Reviewed-by: Nathan Bossart, Bharath Rupireddy, Michael Paquier, Kyotaro Horiguchi, Andres Freund
Discussion: https://postgr.es/m/e5cf6684d17c8d1ef4904ae248605ccd6da03e72.camel@j-davis.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f0b051e322d530a340e62f2ae16d99acdbcb3d05
Modified Files
--------------
doc/src/sgml/func.sgml | 1 -
src/backend/catalog/system_functions.sql | 2 ++
src/backend/utils/adt/mcxtfuncs.c | 14 ++++--------
src/include/catalog/catversion.h | 2 +-
src/test/regress/expected/misc_functions.out | 33 ++++++++++++++++++++++++++--
src/test/regress/sql/misc_functions.sql | 26 ++++++++++++++++++++--
6 files changed, 62 insertions(+), 16 deletions(-)
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts().
2021-10-26 20:41 pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Jeff Davis <jdavis@postgresql.org>
@ 2021-10-27 04:15 ` Michael Paquier <michael@paquier.xyz>
2021-10-27 04:57 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2021-10-27 15:12 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Jeff Davis <pgsql@j-davis.com>
0 siblings, 2 replies; 8+ messages in thread
From: Michael Paquier @ 2021-10-27 04:15 UTC (permalink / raw)
To: Jeff Davis <jdavis@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org
On Tue, Oct 26, 2021 at 08:41:11PM +0000, Jeff Davis wrote:
> Allow GRANT on pg_log_backend_memory_contexts().
>
> Remove superuser check, allowing any user granted permissions on
> pg_log_backend_memory_contexts() to log the memory contexts of any
> backend.
>
> Note that this could allow a privileged non-superuser to log the
> memory contexts of a superuser backend, but as discussed, that does
> not seem to be a problem.
but will not be sent to the client regardless of
<xref linkend="guc-client-min-messages"/>.
- Only superusers can request to log the memory contexts.
</para></entry>
I don't think that the documentation part of this commit is correct.
This sentence should have been changed to something like the
following:
"This function is restricted to superusers by default, but other users
can be granted EXECUTE to run the function."
Thanks,
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts().
2021-10-26 20:41 pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Jeff Davis <jdavis@postgresql.org>
2021-10-27 04:15 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Michael Paquier <michael@paquier.xyz>
@ 2021-10-27 04:57 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2021-10-27 05:03 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Michael Paquier <michael@paquier.xyz>
1 sibling, 1 reply; 8+ messages in thread
From: Bharath Rupireddy @ 2021-10-27 04:57 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Jeff Davis <jdavis@postgresql.org>; pgsql-committers@lists.postgresql.org
On Wed, Oct 27, 2021 at 9:45 AM Michael Paquier <michael@paquier.xyz> wrote:
>
> On Tue, Oct 26, 2021 at 08:41:11PM +0000, Jeff Davis wrote:
> > Allow GRANT on pg_log_backend_memory_contexts().
> >
> > Remove superuser check, allowing any user granted permissions on
> > pg_log_backend_memory_contexts() to log the memory contexts of any
> > backend.
> >
> > Note that this could allow a privileged non-superuser to log the
> > memory contexts of a superuser backend, but as discussed, that does
> > not seem to be a problem.
>
> but will not be sent to the client regardless of
> <xref linkend="guc-client-min-messages"/>.
> - Only superusers can request to log the memory contexts.
> </para></entry>
> I don't think that the documentation part of this commit is correct.
> This sentence should have been changed to something like the
> following:
> "This function is restricted to superusers by default, but other users
> can be granted EXECUTE to run the function."
+1 and the above statement looks good. Apart from that I have one more
suggestion that I earlier made: have the function produce the error
when no permissions were granted (just to ensure we have the error
message covered) including has_function_privilege() case.
Attached a patch with the above documentation change and the error
case added. Please review it.
Regards,
Bharath Rupireddy.
Attachments:
v1-0001-add-docs-and-error-test-case-for-pg_log_backend_m.patch (application/octet-stream, 2.4K) download
From fa3667ddaf66e17131165fb5a7395607da080a19 Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Wed, 27 Oct 2021 04:53:36 +0000
Subject: [PATCH v1] add docs and error test case for
pg_log_backend_memory_contexts
The commit f0b051e322 missed to add docs related to permissions
and an error test case. This patch adds both of them.
---
doc/src/sgml/func.sgml | 2 ++
src/test/regress/expected/misc_functions.out | 4 ++++
src/test/regress/sql/misc_functions.sql | 4 ++++
3 files changed, 10 insertions(+)
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 4b49dff2ff..5be1d75063 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -25332,6 +25332,8 @@ SELECT collation for ('foo' COLLATE "de_DE");
(See <xref linkend="runtime-config-logging"/> for more information),
but will not be sent to the client regardless of
<xref linkend="guc-client-min-messages"/>.
+ This function is restricted to superusers by default, but other users
+ can be granted EXECUTE to run the function.
</para></entry>
</row>
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index 71d316cad3..525d1e19c6 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -155,6 +155,10 @@ SELECT has_function_privilege('regress_log_memory',
f
(1 row)
+SET ROLE regress_log_memory;
+SELECT pg_log_backend_memory_contexts(pg_backend_pid()); -- ERROR
+ERROR: permission denied for function pg_log_backend_memory_contexts
+RESET ROLE;
GRANT EXECUTE ON FUNCTION pg_log_backend_memory_contexts(integer)
TO regress_log_memory;
SELECT has_function_privilege('regress_log_memory',
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index 8c23874b3f..c3cfd96046 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -46,6 +46,10 @@ CREATE ROLE regress_log_memory;
SELECT has_function_privilege('regress_log_memory',
'pg_log_backend_memory_contexts(integer)', 'EXECUTE'); -- no
+SET ROLE regress_log_memory;
+SELECT pg_log_backend_memory_contexts(pg_backend_pid()); -- ERROR
+RESET ROLE;
+
GRANT EXECUTE ON FUNCTION pg_log_backend_memory_contexts(integer)
TO regress_log_memory;
--
2.25.1
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts().
2021-10-26 20:41 pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Jeff Davis <jdavis@postgresql.org>
2021-10-27 04:15 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Michael Paquier <michael@paquier.xyz>
2021-10-27 04:57 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
@ 2021-10-27 05:03 ` Michael Paquier <michael@paquier.xyz>
2021-10-27 05:15 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: Michael Paquier @ 2021-10-27 05:03 UTC (permalink / raw)
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>; +Cc: Jeff Davis <jdavis@postgresql.org>; pgsql-committers@lists.postgresql.org
On Wed, Oct 27, 2021 at 10:27:18AM +0530, Bharath Rupireddy wrote:
> +1 and the above statement looks good. Apart from that I have one more
> suggestion that I earlier made: have the function produce the error
> when no permissions were granted (just to ensure we have the error
> message covered) including has_function_privilege() case.
has_function_privilege() makes sure of the same thing, so I think that
what Jeff has done for this part is just but fine. There is no need
for more duplication in the tests.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts().
2021-10-26 20:41 pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Jeff Davis <jdavis@postgresql.org>
2021-10-27 04:15 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Michael Paquier <michael@paquier.xyz>
2021-10-27 04:57 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2021-10-27 05:03 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Michael Paquier <michael@paquier.xyz>
@ 2021-10-27 05:15 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
0 siblings, 0 replies; 8+ messages in thread
From: Bharath Rupireddy @ 2021-10-27 05:15 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Jeff Davis <jdavis@postgresql.org>; pgsql-committers@lists.postgresql.org
On Wed, Oct 27, 2021 at 10:33 AM Michael Paquier <michael@paquier.xyz> wrote:
>
> On Wed, Oct 27, 2021 at 10:27:18AM +0530, Bharath Rupireddy wrote:
> > +1 and the above statement looks good. Apart from that I have one more
> > suggestion that I earlier made: have the function produce the error
> > when no permissions were granted (just to ensure we have the error
> > message covered) including has_function_privilege() case.
>
> has_function_privilege() makes sure of the same thing, so I think that
> what Jeff has done for this part is just but fine. There is no need
> for more duplication in the tests.
Fair enough.
Regards,
Bharath Rupireddy.
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts().
2021-10-26 20:41 pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Jeff Davis <jdavis@postgresql.org>
2021-10-27 04:15 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Michael Paquier <michael@paquier.xyz>
@ 2021-10-27 15:12 ` Jeff Davis <pgsql@j-davis.com>
2021-10-27 23:47 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Michael Paquier <michael@paquier.xyz>
2021-10-28 13:32 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Alvaro Herrera <alvherre@alvh.no-ip.org>
1 sibling, 2 replies; 8+ messages in thread
From: Jeff Davis @ 2021-10-27 15:12 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; Jeff Davis <jdavis@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org
On Wed, 2021-10-27 at 13:15 +0900, Michael Paquier wrote:
> I don't think that the documentation part of this commit is correct.
> This sentence should have been changed to something like the
> following:
> "This function is restricted to superusers by default, but other
> users
> can be granted EXECUTE to run the function."
Above the table of functions it already says:
"Use of these functions is restricted to superusers by default but
access may be granted to others using GRANT, with noted exceptions."
It looks like several people missed that, so perhaps we should get rid
of that statement at the top, and move it in to each function
description?
Regards,
Jeff Davis
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts().
2021-10-26 20:41 pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Jeff Davis <jdavis@postgresql.org>
2021-10-27 04:15 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Michael Paquier <michael@paquier.xyz>
2021-10-27 15:12 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Jeff Davis <pgsql@j-davis.com>
@ 2021-10-27 23:47 ` Michael Paquier <michael@paquier.xyz>
1 sibling, 0 replies; 8+ messages in thread
From: Michael Paquier @ 2021-10-27 23:47 UTC (permalink / raw)
To: Jeff Davis <pgsql@j-davis.com>; +Cc: Jeff Davis <jdavis@postgresql.org>; pgsql-committers@lists.postgresql.org
On Wed, Oct 27, 2021 at 08:12:23AM -0700, Jeff Davis wrote:
> It looks like several people missed that, so perhaps we should get rid
> of that statement at the top, and move it in to each function
> description?
Oops, you are right, sorry about the useless noise. With a table that
includes all the functions and a description at the top, it looks
fine. Thanks!
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts().
2021-10-26 20:41 pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Jeff Davis <jdavis@postgresql.org>
2021-10-27 04:15 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Michael Paquier <michael@paquier.xyz>
2021-10-27 15:12 ` Re: pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Jeff Davis <pgsql@j-davis.com>
@ 2021-10-28 13:32 ` Alvaro Herrera <alvherre@alvh.no-ip.org>
1 sibling, 0 replies; 8+ messages in thread
From: Alvaro Herrera @ 2021-10-28 13:32 UTC (permalink / raw)
To: Jeff Davis <pgsql@j-davis.com>; +Cc: Michael Paquier <michael@paquier.xyz>; Jeff Davis <jdavis@postgresql.org>; pgsql-committers@lists.postgresql.org
On 2021-Oct-27, Jeff Davis wrote:
> Above the table of functions it already says:
>
> "Use of these functions is restricted to superusers by default but
> access may be granted to others using GRANT, with noted exceptions."
>
> It looks like several people missed that, so perhaps we should get rid
> of that statement at the top, and move it in to each function
> description?
Looking at the output in the website, I agree it looks OK as you left
it and no further patching is necessary.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2021-10-28 13:32 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-10-26 20:41 pgsql: Allow GRANT on pg_log_backend_memory_contexts(). Jeff Davis <jdavis@postgresql.org>
2021-10-27 04:15 ` Michael Paquier <michael@paquier.xyz>
2021-10-27 04:57 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2021-10-27 05:03 ` Michael Paquier <michael@paquier.xyz>
2021-10-27 05:15 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2021-10-27 15:12 ` Jeff Davis <pgsql@j-davis.com>
2021-10-27 23:47 ` Michael Paquier <michael@paquier.xyz>
2021-10-28 13:32 ` Alvaro Herrera <alvherre@alvh.no-ip.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox