Skip to content
Snippets Groups Projects
Commit bfed4ab8 authored by Stephen Frost's avatar Stephen Frost
Browse files

Disallow SET SESSION AUTHORIZATION pg_*

As part of reserving the pg_* namespace for default roles and in line
with SET ROLE and other previous efforts, disallow settings the role
to a default/reserved role using SET SESSION AUTHORIZATION.

These checks and restrictions on what is allowed regarding default /
reserved roles are under debate, but it seems prudent to ensure that
the existing checks at least cover the intended cases while the
debate rages on.  On me to clean it up if the consensus decision is
to remove these checks.
parent be65eddd
No related branches found
No related tags found
No related merge requests found
...@@ -794,6 +794,10 @@ check_session_authorization(char **newval, void **extra, GucSource source) ...@@ -794,6 +794,10 @@ check_session_authorization(char **newval, void **extra, GucSource source)
return false; return false;
} }
/* Do not allow setting role to a reserved role. */
if (strncmp(*newval, "pg_", 3) == 0)
return false;
/* Look up the username */ /* Look up the username */
roleTup = SearchSysCache1(AUTHNAME, PointerGetDatum(*newval)); roleTup = SearchSysCache1(AUTHNAME, PointerGetDatum(*newval));
if (!HeapTupleIsValid(roleTup)) if (!HeapTupleIsValid(roleTup))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment