Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ac372f

Browse files
committed
Add a function to get the authenticated user ID.
Previously, this was not exposed outside of miscinit.c. It is neededfor the pending pg_background patch, and will also be needed forparallelism. Without it, there's no way for a background worker tore-create the exact authentication environment that was present in theprocess that started it, which could lead to security exposures.
1 parentc7371c4 commit5ac372f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

‎src/backend/utils/init/miscinit.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,16 @@ SetSessionUserId(Oid userid, bool is_superuser)
222222
CurrentUserId=userid;
223223
}
224224

225+
/*
226+
* GetAuthenticatedUserId - get the authenticated user ID
227+
*/
228+
Oid
229+
GetAuthenticatedUserId(void)
230+
{
231+
AssertState(OidIsValid(AuthenticatedUserId));
232+
returnAuthenticatedUserId;
233+
}
234+
225235

226236
/*
227237
* GetUserIdAndSecContext/SetUserIdAndSecContext - get/set the current user ID

‎src/include/miscadmin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ extern char *GetUserNameFromId(Oid roleid);
283283
externOidGetUserId(void);
284284
externOidGetOuterUserId(void);
285285
externOidGetSessionUserId(void);
286+
externOidGetAuthenticatedUserId(void);
286287
externvoidGetUserIdAndSecContext(Oid*userid,int*sec_context);
287288
externvoidSetUserIdAndSecContext(Oiduserid,intsec_context);
288289
externboolInLocalUserIdChange(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp