Add option to bgworkers to allow the bypass of role login check
authorMichael Paquier <michael@paquier.xyz>
Thu, 12 Oct 2023 00:24:17 +0000 (09:24 +0900)
committerMichael Paquier <michael@paquier.xyz>
Thu, 12 Oct 2023 00:24:17 +0000 (09:24 +0900)
commite7689190b3d58404abbafe2d3312c3268a51cca3
tree4ce8a0d0de6b99fd05ca0ab526fa4ea863d8a4f4
parentb6a77c6a6ccf698787201b001cbbbf9c89fe5715
Add option to bgworkers to allow the bypass of role login check

This adds a new option called BGWORKER_BYPASS_ROLELOGINCHECK to the
flags available to BackgroundWorkerInitializeConnection() and
BackgroundWorkerInitializeConnectionByOid().

This gives the possibility to bgworkers to bypass the role login check,
making possible the use of a role that has no login rights while not
being a superuser.  PostgresInit() gains a new flag called
INIT_PG_OVERRIDE_ROLE_LOGIN, taking advantage of the refactoring done in
4800a5dfb4c4.

Regression tests are added to worker_spi to check the behavior of this
new option with bgworkers.

Author: Bertrand Drouvot
Reviewed-by: Nathan Bossart, Michael Paquier, Bharath Rupireddy
Discussion: https://postgr.es/m/bcc36259-7850-4882-97ef-d6b905d2fc51@gmail.com
doc/src/sgml/bgworker.sgml
src/backend/postmaster/postmaster.c
src/backend/utils/init/miscinit.c
src/backend/utils/init/postinit.c
src/include/miscadmin.h
src/include/postmaster/bgworker.h
src/test/modules/worker_spi/t/001_worker_spi.pl
src/test/modules/worker_spi/worker_spi.c