Contents

Veil2
Postgres extension for VPD implementations
veil2.c
Go to the documentation of this file.
60 static bool session_ready = false;
67 static int result_counts[] = {0, 0};
74 typedef struct {
76  int scope;
77  Bitmap *privileges;
83 typedef struct {
86  int array_len;
89  ContextPrivs context_privs[0];
96 static SessionPrivs *session_privs = NULL;
101 static bool session_privs_loaded = false;
120 findContext(int *p_idx, int scope_type, int scope)
183 checkContext(int *p_idx, int scope_type, int scope, int priv)
185  findContext(p_idx, scope_type, scope);
228 #define CONTEXT_PRIVS_INCREMENT 16
235 #define CONTEXT_PRIVS_SIZE(elems) ( \
283 add_scope_privs(int scope_type, int scope, Bitmap *privs)
318 fetch_scope_privs(HeapTuple tuple, TupleDesc tupdesc, void *p_result)
329  add_scope_privs(scope_type, scope, privs);
393  veil2_spi_connect(&pushed, "error_if_no_session() (1)");
399  veil2_spi_finish(pushed, "error_if_no_session (2)");
422 fetch_2ints(HeapTuple tuple, TupleDesc tupdesc, void *p_result)
425  tuple_2ints *my_tup = (tuple_2ints *) p_result;
426  my_tup->f1 = DatumGetInt32(SPI_getbinval(tuple, tupdesc, 1, &isnull));
427  my_tup->f2 = DatumGetInt32(SPI_getbinval(tuple, tupdesc, 2, &isnull));
470 truncate_temp_tables(bool clear_context)
496 veil2_session_ready(PG_FUNCTION_ARGS)
509 do_reset_session(bool clear_context)
526  fetch_2ints, (void *) &my_tup);
588 veil2_reset_session(PG_FUNCTION_ARGS)
594  veil2_spi_connect(&pushed, "failed to reset session (1)");
596  veil2_spi_finish(pushed, "failed to reset session (2)");
609 veil2_reset_session_privs(PG_FUNCTION_ARGS)
614  veil2_spi_connect(&pushed, "failed to reset session privs (1)");
616  veil2_spi_finish(pushed, "failed to reset session privs (2)");
630 veil2_true(PG_FUNCTION_ARGS)
669 veil2_i_have_global_priv(PG_FUNCTION_ARGS)
677  result = checkContext(&context_idx, 1, 0, priv);
699 veil2_i_have_personal_priv(PG_FUNCTION_ARGS)
708  result = checkContext(&context_idx, 2, accessor_id, priv);
731 veil2_i_have_priv_in_scope(PG_FUNCTION_ARGS)
741  result = checkContext(&context_idx, scope_type_id, scope_id, priv);
776  (checkContext(&global_context_idx, 1, 0, priv) ||
777  checkContext(&given_context_idx, scope_type_id,
877  result = checkContext(&context_idx, scope_type_id, scope_id, priv);
943  (checkContext(&global_context_idx, 1, 0, priv) ||
944  checkContext(&given_context_idx, scope_type_id,
980 veil2_result_counts(PG_FUNCTION_ARGS)
1009 textfromstr(char *in)
1025 veil2_docpath(PG_FUNCTION_ARGS)
1037 veil2_datapath(PG_FUNCTION_ARGS)
Datum veil2_datapath(FunctionCallInfo fcinfo)
Definition: veil2.c:1037
#define CONTEXT_PRIVS_SIZE(elems)
Definition: veil2.c:235
Datum veil2_reset_session_privs(FunctionCallInfo fcinfo)
Definition: veil2.c:609
ContextPrivs context_privs[0]
Definition: veil2.c:89
int active_contexts
Definition: veil2.c:88
static int result_counts[]
Definition: veil2.c:67
static bool fetch_scope_privs(HeapTuple tuple, TupleDesc tupdesc, void *p_result)
Definition: veil2.c:318
#define DOCS_PATH
Definition: veil2.h:84
Main header file for veil2.
static void do_load_session_privs()
Definition: veil2.c:338
Datum veil2_i_have_priv_in_scope_or_global(FunctionCallInfo fcinfo)
Definition: veil2.c:764
int f1
Definition: veil2.h:30
static void clear_session_privs()
Definition: veil2.c:212
static SessionPrivs * extendSessionPrivs(SessionPrivs *session_privs)
Definition: veil2.c:246
void veil2_spi_finish(bool pushed, const char *msg)
Definition: query.c:66
Datum veil2_i_have_priv_in_scope_or_superior_or_global(FunctionCallInfo fcinfo)
Definition: veil2.c:924
Datum veil2_true(FunctionCallInfo fcinfo)
Definition: veil2.c:630
static void findContext(int *p_idx, int scope_type, int scope)
Definition: veil2.c:120
#define DATA_PATH
Definition: veil2.h:88
static void truncate_temp_tables(bool clear_context)
Definition: veil2.c:470
static bool fetch_2ints(HeapTuple tuple, TupleDesc tupdesc, void *p_result)
Definition: veil2.c:422
static bool checkContext(int *p_idx, int scope_type, int scope, int priv)
Definition: veil2.c:183
Datum veil2_session_ready(FunctionCallInfo fcinfo)
Definition: veil2.c:496
Datum veil2_i_have_priv_in_scope_or_superior(FunctionCallInfo fcinfo)
Definition: veil2.c:857
static void load_privs()
Definition: veil2.c:368
static void create_temp_tables()
Definition: veil2.c:438
Datum veil2_i_have_global_priv(FunctionCallInfo fcinfo)
Definition: veil2.c:669
static text * textfromstr(char *in)
Definition: veil2.c:1009
int array_len
Definition: veil2.c:86
static void add_scope_privs(int scope_type, int scope, Bitmap *privs)
Definition: veil2.c:283
int scope
Definition: veil2.c:76
#define CONTEXT_PRIVS_INCREMENT
Definition: veil2.c:228
int f2
Definition: veil2.h:32
static bool checkSessionReady()
Definition: veil2.c:644
bool veil2_bool_from_query(const char *qry, int nargs, Oid *argtypes, Datum *args, void **saved_plan, bool *result)
Definition: query.c:267
static void freeContextPrivs(ContextPrivs *cp)
Definition: veil2.c:201
Datum veil2_reset_session(FunctionCallInfo fcinfo)
Definition: veil2.c:588
Datum veil2_i_have_priv_in_scope(FunctionCallInfo fcinfo)
Definition: veil2.c:731
Datum veil2_result_counts(FunctionCallInfo fcinfo)
Definition: veil2.c:980
static void do_reset_session(bool clear_context)
Definition: veil2.c:509
Datum veil2_docpath(FunctionCallInfo fcinfo)
Definition: veil2.c:1025
static SessionPrivs * session_privs
Definition: veil2.c:96
int veil2_query(const char *qry, int nargs, Oid *argtypes, Datum *args, bool read_only, void **saved_plan, Fetch_fn process_row, void *fn_param)
Definition: query.c:218
static bool error_if_no_session()
Definition: veil2.c:387
void veil2_spi_connect(bool *p_pushed, const char *msg)
Definition: query.c:38
int scope_type
Definition: veil2.c:75
static bool session_privs_loaded
Definition: veil2.c:101
Datum veil2_i_have_personal_priv(FunctionCallInfo fcinfo)
Definition: veil2.c:699
Bitmap * privileges
Definition: veil2.c:77
Datum veil2_i_have_priv_in_superior_scope(FunctionCallInfo fcinfo)
Definition: veil2.c:801
static bool session_ready
Definition: veil2.c:60