1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Fix per-session activation of ALTER {ROLE|DATABASE} SET role.

After commit 5a2fed911a, the catalog state
resulting from these commands ceased to affect sessions.  Restore the
longstanding behavior, which is like beginning the session with a SET
ROLE command.  If cherry-picking the CVE-2024-10978 fixes, default to
including this, too.  (This fixes an unintended side effect of fixing
CVE-2024-10978.)  Back-patch to v12, like that commit.  The release team
decided to include v12, despite the original intent to halt v12 commits
earlier this week.

Tom Lane and Noah Misch.  Reported by Etienne LAFARGE.

Discussion: https://postgr.es/m/CADOZwSb0UsEr4_UTFXC5k7=fyyK8uKXekucd+-uuGjJsGBfxgw@mail.gmail.com
This commit is contained in:
Noah Misch
2024-11-15 20:39:56 -08:00
parent e5ed873b1b
commit 7b88529f43
6 changed files with 90 additions and 3 deletions

View File

@ -4099,6 +4099,12 @@ set_config_with_handle(const char *name, config_handle *handle,
* expect that if "role" isn't supposed to be default, it
* has been or will be set by a separate reload action.
*
* Also, for the call from InitializeSessionUserId with
* source == PGC_S_OVERRIDE, use PGC_S_DYNAMIC_DEFAULT for
* "role"'s source, so that it's still possible to set
* "role" from pg_db_role_setting entries. (See notes in
* InitializeSessionUserId before changing this.)
*
* A fine point: for RESET session_authorization, we do
* "RESET role" not "SET ROLE NONE" (by passing down NULL
* rather than "none" for the value). This would have the
@ -4111,7 +4117,9 @@ set_config_with_handle(const char *name, config_handle *handle,
(void) set_config_with_handle("role", NULL,
value ? "none" : NULL,
orig_context,
orig_source,
(orig_source == PGC_S_OVERRIDE)
? PGC_S_DYNAMIC_DEFAULT
: orig_source,
orig_srole,
action,
true,