diff options
author | Robert Haas <rhaas@postgresql.org> | 2014-10-23 08:18:45 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2014-10-23 08:18:45 -0400 |
commit | 5ac372fc1a7cc673cc7d4cf26ba651d52495b27a (patch) | |
tree | 0a7e62bc9cd02ff6eb908a416d5aebe76c85f0f4 /src | |
parent | c7371c4a607872c4d799e0dac0c9367574067cdc (diff) | |
download | postgresql-5ac372fc1a7cc673cc7d4cf26ba651d52495b27a.tar.gz postgresql-5ac372fc1a7cc673cc7d4cf26ba651d52495b27a.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/init/miscinit.c | 10 | ||||
-rw-r--r-- | src/include/miscadmin.h | 1 |
2 files changed, 11 insertions, 0 deletions
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 diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 2ba98856ff2..1558a75fbde 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -283,6 +283,7 @@ extern char *GetUserNameFromId(Oid roleid); extern Oid GetUserId(void); extern Oid GetOuterUserId(void); extern Oid GetSessionUserId(void); +extern Oid GetAuthenticatedUserId(void); extern void GetUserIdAndSecContext(Oid *userid, int *sec_context); extern void SetUserIdAndSecContext(Oid userid, int sec_context); extern bool InLocalUserIdChange(void); |