mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
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
4800a5dfb4.
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
This commit is contained in:
@@ -5567,6 +5567,9 @@ BackgroundWorkerInitializeConnection(const char *dbname, const char *username, u
|
||||
/* ignore datallowconn? */
|
||||
if (flags & BGWORKER_BYPASS_ALLOWCONN)
|
||||
init_flags |= INIT_PG_OVERRIDE_ALLOW_CONNS;
|
||||
/* ignore rolcanlogin? */
|
||||
if (flags & BGWORKER_BYPASS_ROLELOGINCHECK)
|
||||
init_flags |= INIT_PG_OVERRIDE_ROLE_LOGIN;
|
||||
|
||||
/* XXX is this the right errcode? */
|
||||
if (!(worker->bgw_flags & BGWORKER_BACKEND_DATABASE_CONNECTION))
|
||||
@@ -5598,6 +5601,9 @@ BackgroundWorkerInitializeConnectionByOid(Oid dboid, Oid useroid, uint32 flags)
|
||||
/* ignore datallowconn? */
|
||||
if (flags & BGWORKER_BYPASS_ALLOWCONN)
|
||||
init_flags |= INIT_PG_OVERRIDE_ALLOW_CONNS;
|
||||
/* ignore rolcanlogin? */
|
||||
if (flags & BGWORKER_BYPASS_ROLELOGINCHECK)
|
||||
init_flags |= INIT_PG_OVERRIDE_ROLE_LOGIN;
|
||||
|
||||
/* XXX is this the right errcode? */
|
||||
if (!(worker->bgw_flags & BGWORKER_BACKEND_DATABASE_CONNECTION))
|
||||
|
||||
Reference in New Issue
Block a user