Allow granting SET and ALTER SYSTEM privileges on GUC parameters.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: a0ffa885e478f5eeacc4e250e35ce25a4740c487
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2022-04-06T17:24:33Z
Releases: 15.0
Allow granting SET and ALTER SYSTEM privileges on GUC parameters.

This patch allows "PGC_SUSET" parameters to be set by non-superusers
if they have been explicitly granted the privilege to do so.
The privilege to perform ALTER SYSTEM SET/RESET on a specific parameter
can also be granted.
Such privileges are cluster-wide, not per database.  They are tracked
in a new shared catalog, pg_parameter_acl.

Granting and revoking these new privileges works as one would expect.
One caveat is that PGC_USERSET GUCs are unaffected by the SET privilege
--- one could wish that those were handled by a revocable grant to
PUBLIC, but they are not, because we couldn't make it robust enough
for GUCs defined by extensions.

Mark Dilger, reviewed at various times by Andrew Dunstan, Robert Haas,
Joshua Brindle, and myself

Discussion: https://postgr.es/m/3D691E20-C1D5-4B80-8BA5-6BEB63AF3029@enterprisedb.com

Files

PathChange+/−
doc/src/sgml/catalogs.sgml modified +76 −1
doc/src/sgml/config.sgml modified +99 −51
doc/src/sgml/ddl.sgml modified +42 −2
doc/src/sgml/func.sgml modified +22 −2
doc/src/sgml/ref/alter_system.sgml modified +2 −1
doc/src/sgml/ref/drop_owned.sgml modified +2 −2
doc/src/sgml/ref/grant.sgml modified +13 −4
doc/src/sgml/ref/pg_dumpall.sgml modified +2 −1
doc/src/sgml/ref/revoke.sgml modified +7 −0
doc/src/sgml/ref/set.sgml modified +4 −2
src/backend/catalog/aclchk.c modified +354 −3
src/backend/catalog/catalog.c modified +21 −15
src/backend/catalog/dependency.c modified +6 −0
src/backend/catalog/Makefile modified +3 −1
src/backend/catalog/objectaddress.c modified +71 −0
src/backend/catalog/pg_parameter_acl.c added +118 −0
src/backend/commands/alter.c modified +1 −0
src/backend/commands/event_trigger.c modified +5 −0
src/backend/commands/seclabel.c modified +1 −0
src/backend/commands/tablecmds.c modified +1 −0
src/backend/parser/gram.y modified +43 −3
src/backend/utils/adt/acl.c modified +114 −0
src/backend/utils/cache/syscache.c modified +23 −0
src/backend/utils/misc/guc.c modified +125 −21
src/bin/pg_dump/dumputils.c modified +6 −1
src/bin/pg_dump/pg_dumpall.c modified +65 −0
src/bin/psql/tab-complete.c modified +69 −9
src/include/catalog/catversion.h modified +1 −1
src/include/catalog/dependency.h modified +1 −0
src/include/catalog/objectaccess.h modified +1 −1
src/include/catalog/pg_parameter_acl.h added +62 −0
src/include/catalog/pg_proc.dat modified +16 −0
src/include/nodes/parsenodes.h modified +3 −2
src/include/parser/kwlist.h modified +1 −0
src/include/utils/acl.h modified +10 −1
src/include/utils/guc.h modified +2 −0
src/include/utils/syscache.h modified +2 −0
src/test/modules/test_oat_hooks/expected/test_oat_hooks.out modified +153 −62
src/test/modules/test_oat_hooks/sql/test_oat_hooks.sql modified +48 −1
src/test/modules/test_oat_hooks/test_oat_hooks.c modified +74 −6
src/test/modules/test_pg_dump/t/001_base.pl modified +32 −0
src/test/modules/unsafe_tests/expected/guc_privs.out added +526 −0
src/test/modules/unsafe_tests/Makefile modified +1 −1
src/test/modules/unsafe_tests/sql/guc_privs.sql added +237 −0

Documentation touched

Discussion