PostgreSQL Source Code: src/test/modules/test_oat_hooks/test_oat_hooks.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
15
23
25
26
27
28
35
36
37
38
39
44
45
50
51
64
65
68
69
70
71
72
73void
75{
76
77
78
80 "Deny non-superuser set permissions",
83 false,
89
90
91
92
94 "Deny non-superuser alter system set permissions",
97 false,
103
104
105
106
108 "Deny non-superuser object access permissions",
111 false,
117
118
119
120
122 "Deny non-superuser exec permissions",
125 false,
131
132
133
134
136 "Deny non-superuser utility commands",
139 false,
145
146
147
148
150 "Turn on/off debug audit messages",
153 false,
159
160
161
162
164 "Dummy parameter settable by public",
167 false,
173
175 "Dummy parameter settable by public",
178 false,
184
185
186
187
189 "Dummy parameter settable by superuser",
192 false,
198
200 "Dummy parameter settable by superuser",
203 false,
209
211
212
215
216
219
220
223
224
227}
228
229static void
231{
232
233
234
235
236
238 {
240
245 else
248 errmsg("in %s: %s %s %s", hook, who, type, action)));
249 }
250
251 if (action)
255}
256
257static void
262
263static void
268
269static void
274
275static void
277{
281
283 {
285 }
286
288 {
291 {
295 errmsg("permission denied: all privileges %s", objName)));
296 }
298 {
303 }
305 {
309 errmsg("permission denied: alter system set %s", objName)));
310 }
311 else
312 elog(ERROR, "Unknown ParameterAclRelationId subId: %d", subId);
313 break;
314 default:
315 break;
316 }
317
321}
322
323static void
325{
329
333 errmsg("permission denied: %s [%s]",
336
337
339 (*next_object_access_hook) (access, classId, objectId, subId, arg);
340
344}
345
346static bool
348{
350 bool allow = true;
351
353
354
359 errmsg("permission denied: %s", "execute")));
360
361
365
370 else
374
376}
377
378static void
380 const char *queryString,
387{
390
394
395
399 errmsg("permission denied: %s", action)));
400
401
403 (*next_ProcessUtility_hook) (pstmt, queryString, readOnlyTree,
404 context, params, queryEnv,
405 dest, qc);
406 else
408 context, params, queryEnv,
409 dest, qc);
410
411
415}
416
417static char *
419{
420 const char *type;
421
423 {
425 type = "create";
426 break;
428 type = "drop";
429 break;
431 type = "alter";
432 break;
434 type = "namespace search";
435 break;
437 type = "execute";
438 break;
440 type = "truncate";
441 break;
442 default:
443 type = "UNRECOGNIZED ObjectAccessType";
444 }
445
452
454}
455
456static char *
458{
460 return pstrdup("extra info null");
461
463 {
465 {
467
468 return pstrdup(pc_arg->is_internal ? "internal" : "explicit");
469 }
470 break;
472 {
474
475 return psprintf("%s%s%s%s%s%s",
477 ? "internal action," : ""),
479 ? "concurrent drop," : ""),
481 ? "suppress notices," : ""),
483 ? "keep original object," : ""),
485 ? "keep extensions," : ""),
487 ? "normal concurrent drop," : ""));
488 }
489 break;
491 {
493
494 return psprintf("%s %s auxiliary object",
495 (pa_arg->is_internal ? "internal" : "explicit"),
497 }
498 break;
500 {
502
504 (ns_arg->ereport_on_violation ? "report on violation" : "no report on violation"),
505 (ns_arg->result ? "allowed" : "denied"));
506 }
507 break;
510
511 return pstrdup("unexpected extra info pointer received");
512 default:
513 return pstrdup("cannot parse extra info for unrecognized access type");
514 }
515
516 return pstrdup("unknown");
517}
#define OidIsValid(objectId)
const char * GetCommandTagName(CommandTag commandTag)
#define PERFORM_DELETION_CONCURRENTLY
#define PERFORM_DELETION_SKIP_EXTENSIONS
#define PERFORM_DELETION_CONCURRENT_LOCK
#define PERFORM_DELETION_QUIETLY
#define PERFORM_DELETION_SKIP_ORIGINAL
#define PERFORM_DELETION_INTERNAL
int errcode(int sqlerrcode)
#define ereport(elevel,...)
ExecutorCheckPerms_hook_type ExecutorCheckPerms_hook
bool(* ExecutorCheckPerms_hook_type)(List *rangeTable, List *rtePermInfos, bool ereport_on_violation)
void DefineCustomBoolVariable(const char *name, const char *short_desc, const char *long_desc, bool *valueAddr, bool bootValue, GucContext context, int flags, GucBoolCheckHook check_hook, GucBoolAssignHook assign_hook, GucShowHook show_hook)
void MarkGUCPrefixReserved(const char *className)
#define GUC_NOT_IN_SAMPLE
#define IsParallelWorker()
char * pstrdup(const char *in)
void pfree(void *pointer)
object_access_hook_type object_access_hook
object_access_hook_type_str object_access_hook_str
void(* object_access_hook_type)(ObjectAccessType access, Oid classId, Oid objectId, int subId, void *arg)
void(* object_access_hook_type_str)(ObjectAccessType access, Oid classId, const char *objectStr, int subId, void *arg)
char * psprintf(const char *fmt,...)
bool superuser_arg(Oid roleid)
static bool REGRESS_suset_variable1
static bool REGRESS_deny_exec_perms
static bool REGRESS_deny_object_access
static void REGRESS_utility_command(PlannedStmt *pstmt, const char *queryString, bool readOnlyTree, ProcessUtilityContext context, ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest, QueryCompletion *qc)
static ExecutorCheckPerms_hook_type next_exec_check_perms_hook
static ProcessUtility_hook_type next_ProcessUtility_hook
static void emit_audit_message(const char *type, const char *hook, char *action, char *objName)
static bool REGRESS_deny_set_variable
static bool REGRESS_userset_variable2
static char * accesstype_arg_to_string(ObjectAccessType access, void *arg)
static bool REGRESS_deny_alter_system
static void REGRESS_object_access_hook(ObjectAccessType access, Oid classId, Oid objectId, int subId, void *arg)
static void audit_attempt(const char *hook, char *action, char *objName)
static char * accesstype_to_string(ObjectAccessType access, int subId)
static bool REGRESS_exec_check_perms(List *rangeTabls, List *rteperminfos, bool do_abort)
static bool REGRESS_userset_variable1
static void audit_failure(const char *hook, char *action, char *objName)
static bool REGRESS_deny_utility_commands
static object_access_hook_type next_object_access_hook
static object_access_hook_type_str next_object_access_hook_str
static bool REGRESS_suset_variable2
static void REGRESS_object_access_hook_str(ObjectAccessType access, Oid classId, const char *objName, int subId, void *arg)
static void audit_success(const char *hook, char *action, char *objName)
static bool REGRESS_audit
void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString, bool readOnlyTree, ProcessUtilityContext context, ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest, QueryCompletion *qc)
CommandTag CreateCommandTag(Node *parsetree)
ProcessUtility_hook_type ProcessUtility_hook
void(* ProcessUtility_hook_type)(PlannedStmt *pstmt, const char *queryString, bool readOnlyTree, ProcessUtilityContext context, ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest, QueryCompletion *qc)