Add security utils

cimv
Sait Talha Nisanci 2020-12-30 14:18:40 +03:00
parent 1b16a9fe02
commit ff03b35f94
1 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
/*-------------------------------------------------------------------------
*
* security_utils.h
* security related utility functions.
*
* Copyright (c) Citus Data, Inc.
*
*-------------------------------------------------------------------------
*/
#ifndef SECURITY_UTILS_H_
#define SECURITY_UTILS_H_
#include "postgres.h"
#include "miscadmin.h"
#define PushCitusSecurityContext() \
Oid savedUserId_DONTUSE = InvalidOid; \
int savedSecurityContext_DONTUSE = 0; \
GetUserIdAndSecContext(&savedUserId_DONTUSE, &savedSecurityContext_DONTUSE); \
SetUserIdAndSecContext(CitusExtensionOwner(), SECURITY_LOCAL_USERID_CHANGE);
#define PopCitusSecurityContext() \
SetUserIdAndSecContext(savedUserId_DONTUSE, savedSecurityContext_DONTUSE);
#endif