1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-01 01:04:50 +03:00

Tidy up Object Access hooks tests

per gripelet from Tom Lane.
This commit is contained in:
Andrew Dunstan 2022-03-22 16:18:06 -04:00
parent f0206d9952
commit a3b071bbe0
4 changed files with 8 additions and 6 deletions

View File

@ -1,13 +1,10 @@
# src/test/modules/test_oat_hooks/Makefile # src/test/modules/test_oat_hooks/Makefile
MODULE_big = test_oat_hooks MODULE_big = test_oat_hooks
OBJS = \ OBJS = test_oat_hooks.o $(WIN32RES)
$(WIN32RES) \
test_oat_hooks.o
PGFILEDESC = "test_oat_hooks - example use of object access hooks" PGFILEDESC = "test_oat_hooks - example use of object access hooks"
REGRESS = test_oat_hooks REGRESS = test_oat_hooks
NO_INSTALLCHECK = 1
ifdef USE_PGXS ifdef USE_PGXS
PG_CONFIG = pg_config PG_CONFIG = pg_config

View File

@ -155,7 +155,7 @@ NOTICE: in process utility: superuser attempting set
NOTICE: in object_access_hook_str: superuser attempting alter (set) [test_oat_hooks.deny_utility_commands] NOTICE: in object_access_hook_str: superuser attempting alter (set) [test_oat_hooks.deny_utility_commands]
NOTICE: in object_access_hook_str: superuser finished alter (set) [test_oat_hooks.deny_utility_commands] NOTICE: in object_access_hook_str: superuser finished alter (set) [test_oat_hooks.deny_utility_commands]
NOTICE: in process utility: superuser finished set NOTICE: in process utility: superuser finished set
-- Try again as non-superuser with permisisons denied -- Try again as non-superuser with permissions denied
SET SESSION AUTHORIZATION regress_test_user; SET SESSION AUTHORIZATION regress_test_user;
NOTICE: in process utility: superuser attempting set NOTICE: in process utility: superuser attempting set
NOTICE: in object_access_hook_str: non-superuser attempting alter (set) [session_authorization] NOTICE: in object_access_hook_str: non-superuser attempting alter (set) [session_authorization]

View File

@ -39,7 +39,7 @@ SET test_oat_hooks.deny_object_access = true;
SET test_oat_hooks.deny_exec_perms = true; SET test_oat_hooks.deny_exec_perms = true;
SET test_oat_hooks.deny_utility_commands = true; SET test_oat_hooks.deny_utility_commands = true;
-- Try again as non-superuser with permisisons denied -- Try again as non-superuser with permissions denied
SET SESSION AUTHORIZATION regress_test_user; SET SESSION AUTHORIZATION regress_test_user;
SELECT * FROM regress_test_table; SELECT * FROM regress_test_table;
SELECT regress_test_func('arg'); SELECT regress_test_func('arg');

View File

@ -192,6 +192,11 @@ _PG_fini(void)
static void static void
emit_audit_message(const char *type, const char *hook, char *action, char *objName) emit_audit_message(const char *type, const char *hook, char *action, char *objName)
{ {
/*
* Ensure that audit messages are not duplicated by only emitting them from
* a leader process, not a worker process. This makes the test results
* deterministic even if run with force_parallel_mode = regress.
*/
if (REGRESS_audit && !IsParallelWorker()) if (REGRESS_audit && !IsParallelWorker())
{ {
const char *who = superuser_arg(GetUserId()) ? "superuser" : "non-superuser"; const char *who = superuser_arg(GetUserId()) ? "superuser" : "non-superuser";