Allow granting SET and ALTER SYSTEM privileges on GUC parameters.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 6 Apr 2022 17:24:33 +0000 (13:24 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 6 Apr 2022 17:24:33 +0000 (13:24 -0400)
commita0ffa885e478f5eeacc4e250e35ce25a4740c487
tree7ce236305d5eb50f34bfccaf9a662cf3f0b77adf
parent2ef6f11b0c77ec323c688ddfd98ffabddb72c11d
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
44 files changed:
doc/src/sgml/catalogs.sgml
doc/src/sgml/config.sgml
doc/src/sgml/ddl.sgml
doc/src/sgml/func.sgml
doc/src/sgml/ref/alter_system.sgml
doc/src/sgml/ref/drop_owned.sgml
doc/src/sgml/ref/grant.sgml
doc/src/sgml/ref/pg_dumpall.sgml
doc/src/sgml/ref/revoke.sgml
doc/src/sgml/ref/set.sgml
src/backend/catalog/Makefile
src/backend/catalog/aclchk.c
src/backend/catalog/catalog.c
src/backend/catalog/dependency.c
src/backend/catalog/objectaddress.c
src/backend/catalog/pg_parameter_acl.c [new file with mode: 0644]
src/backend/commands/alter.c
src/backend/commands/event_trigger.c
src/backend/commands/seclabel.c
src/backend/commands/tablecmds.c
src/backend/parser/gram.y
src/backend/utils/adt/acl.c
src/backend/utils/cache/syscache.c
src/backend/utils/misc/guc.c
src/bin/pg_dump/dumputils.c
src/bin/pg_dump/pg_dumpall.c
src/bin/psql/tab-complete.c
src/include/catalog/catversion.h
src/include/catalog/dependency.h
src/include/catalog/objectaccess.h
src/include/catalog/pg_parameter_acl.h [new file with mode: 0644]
src/include/catalog/pg_proc.dat
src/include/nodes/parsenodes.h
src/include/parser/kwlist.h
src/include/utils/acl.h
src/include/utils/guc.h
src/include/utils/syscache.h
src/test/modules/test_oat_hooks/expected/test_oat_hooks.out
src/test/modules/test_oat_hooks/sql/test_oat_hooks.sql
src/test/modules/test_oat_hooks/test_oat_hooks.c
src/test/modules/test_pg_dump/t/001_base.pl
src/test/modules/unsafe_tests/Makefile
src/test/modules/unsafe_tests/expected/guc_privs.out [new file with mode: 0644]
src/test/modules/unsafe_tests/sql/guc_privs.sql [new file with mode: 0644]