diff options
author | Jeff Davis <jdavis@postgresql.org> | 2021-10-26 13:13:52 -0700 |
---|---|---|
committer | Jeff Davis <jdavis@postgresql.org> | 2021-10-26 13:31:38 -0700 |
commit | f0b051e322d530a340e62f2ae16d99acdbcb3d05 (patch) | |
tree | 204674f9392134074f581a36c5ed405401c0f2cd /src/backend/utils/adt/mcxtfuncs.c | |
parent | 5fedf7417b69295294b154a219edd8a26eaa6ab6 (diff) | |
download | postgresql-f0b051e322d530a340e62f2ae16d99acdbcb3d05.tar.gz postgresql-f0b051e322d530a340e62f2ae16d99acdbcb3d05.zip |
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
Diffstat (limited to 'src/backend/utils/adt/mcxtfuncs.c')
-rw-r--r-- | src/backend/utils/adt/mcxtfuncs.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/backend/utils/adt/mcxtfuncs.c b/src/backend/utils/adt/mcxtfuncs.c index 0d52613bc32..6ddbf70b30c 100644 --- a/src/backend/utils/adt/mcxtfuncs.c +++ b/src/backend/utils/adt/mcxtfuncs.c @@ -162,10 +162,10 @@ pg_get_backend_memory_contexts(PG_FUNCTION_ARGS) * pg_log_backend_memory_contexts * Signal a backend process to log its memory contexts. * - * Only superusers are allowed to signal to log the memory contexts - * because allowing any users to issue this request at an unbounded - * rate would cause lots of log messages and which can lead to - * denial of service. + * By default, only superusers are allowed to signal to log the memory + * contexts because allowing any users to issue this request at an unbounded + * rate would cause lots of log messages and which can lead to denial of + * service. Additional roles can be permitted with GRANT. * * On receipt of this signal, a backend sets the flag in the signal * handler, which causes the next CHECK_FOR_INTERRUPTS() to log the @@ -177,12 +177,6 @@ pg_log_backend_memory_contexts(PG_FUNCTION_ARGS) int pid = PG_GETARG_INT32(0); PGPROC *proc; - /* Only allow superusers to log memory contexts. */ - if (!superuser()) - ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be a superuser to log memory contexts"))); - proc = BackendPidGetProc(pid); /* |