From 5ac372fc1a7cc673cc7d4cf26ba651d52495b27a Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 23 Oct 2014 08:18:45 -0400 Subject: Add a function to get the authenticated user ID. Previously, this was not exposed outside of miscinit.c. It is needed for the pending pg_background patch, and will also be needed for parallelism. Without it, there's no way for a background worker to re-create the exact authentication environment that was present in the process that started it, which could lead to security exposures. --- src/backend/utils/init/miscinit.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/backend/utils/init/miscinit.c') diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index a703c67eadd..8fccb4c8262 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -222,6 +222,16 @@ SetSessionUserId(Oid userid, bool is_superuser) CurrentUserId = userid; } +/* + * GetAuthenticatedUserId - get the authenticated user ID + */ +Oid +GetAuthenticatedUserId(void) +{ + AssertState(OidIsValid(AuthenticatedUserId)); + return AuthenticatedUserId; +} + /* * GetUserIdAndSecContext/SetUserIdAndSecContext - get/set the current user ID -- cgit v1.2.3