pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Dilger <mark.dilger@enterprisedb.com>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Julien Rouhaud <rjuju123@gmail.com>
Cc: Joshua Brindle <joshua.brindle@crunchydata.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Jeff Davis <pgsql@j-davis.com>
Cc: Joe Conway <joe@crunchydata.com>
Cc: Stephen Frost <sfrost@snowman.net>
Subject: Re: New Object Access Type hooks
Date: Tue, 22 Mar 2022 09:15:39 -0700
Message-ID: <15D89996-7D4C-486C-9EB6-F0AC6AFEDDA2@enterprisedb.com> (raw)
In-Reply-To: <4420FCB6-16B2-4C28-B9A5-9C5A34A756CB@enterprisedb.com>
References: <47F87A0E-C0E5-43A6-89F6-D403F2B45175@enterprisedb.com>
	<CAGB+Vh5PFQskeJDGCSBYMZHKDP9Wo6hLJ_=SnzE=SQwoXaToiA@mail.gmail.com>
	<E115F20B-87DF-4FB4-9D21-286D0CA70FA1@enterprisedb.com>
	<3ef3f6d7-b7b6-fb90-f3d0-afb1bf2a2cb9@dunslane.net>
	<516E8A9F-76AA-4C08-BDE6-259D62060D62@enterprisedb.com>
	<fdba7277-722b-a4ce-8027-88e4fc6ef0f8@dunslane.net>
	<448E56E1-0C59-441A-A6D0-66B8CFEFE540@enterprisedb.com>
	<7f6d54a1-4024-3b6e-e3ec-26cd394aac9e@dunslane.net>
	<20220322151444.pagugrb7rjmlee2z@jrouhaud>
	<AB996420-4E8B-4A8C-9752-F820FE11B913@enterprisedb.com>
	<f884a990-fd46-e809-86ca-2709d290cb57@dunslane.net>
	<2541365.1647964938@sss.pgh.pa.us>
	<75066591-7437-13b9-aaa0-7d7a4789700c@dunslane.net>
	<4420FCB6-16B2-4C28-B9A5-9C5A34A756CB@enterprisedb.com>



> On Mar 22, 2022, at 9:11 AM, Mark Dilger <mark.dilger@enterprisedb.com> wrote:
> 
> Give me a couple minutes....

—
Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachments:

v1-0001-Fix-build-farm-failures-in-test_oat_hooks.patch (application/octet-stream, 5.8K) download From 669b633dadb8ad7e3ebab373e68e63840454e8ae Mon Sep 17 00:00:00 2001 From: Mark Dilger <mark.dilger@enterprisedb.com> Date: Tue, 22 Mar 2022 09:13:58 -0700 Subject: [PATCH v1] Fix build farm failures in test_oat_hooks The behavior of this regression test was unstable. Fix that. --- .../expected/test_oat_hooks.out | 12 ----- .../modules/test_oat_hooks/test_oat_hooks.c | 47 ------------------- 2 files changed, 59 deletions(-) diff --git a/src/test/modules/test_oat_hooks/expected/test_oat_hooks.out b/src/test/modules/test_oat_hooks/expected/test_oat_hooks.out index 2035769580..07247b4b24 100644 --- a/src/test/modules/test_oat_hooks/expected/test_oat_hooks.out +++ b/src/test/modules/test_oat_hooks/expected/test_oat_hooks.out @@ -46,15 +46,11 @@ NOTICE: in process utility: superuser attempting GrantStmt NOTICE: in process utility: superuser finished GrantStmt -- Do a few things as superuser SELECT * FROM regress_test_table; -NOTICE: in executor check perms: superuser attempting execute -NOTICE: in executor check perms: superuser finished execute t --- (0 rows) SELECT regress_test_func('arg'); -NOTICE: in executor check perms: superuser attempting execute -NOTICE: in executor check perms: superuser finished execute regress_test_func ------------------- arg @@ -93,15 +89,11 @@ LINE 1: SELECT * FROM regress_test_table; NOTICE: in object access: non-superuser finished namespace search (subId=0) [no report on violation, allowed] LINE 1: SELECT * FROM regress_test_table; ^ -NOTICE: in executor check perms: non-superuser attempting execute -NOTICE: in executor check perms: non-superuser finished execute t --- (0 rows) SELECT regress_test_func('arg'); -NOTICE: in executor check perms: non-superuser attempting execute -NOTICE: in executor check perms: non-superuser finished execute regress_test_func ------------------- arg @@ -166,15 +158,11 @@ LINE 1: SELECT * FROM regress_test_table; NOTICE: in object access: superuser finished namespace search (subId=0) [no report on violation, allowed] LINE 1: SELECT * FROM regress_test_table; ^ -NOTICE: in executor check perms: superuser attempting execute -NOTICE: in executor check perms: superuser finished execute t --- (0 rows) SELECT regress_test_func('arg'); -NOTICE: in executor check perms: superuser attempting execute -NOTICE: in executor check perms: superuser finished execute regress_test_func ------------------- arg diff --git a/src/test/modules/test_oat_hooks/test_oat_hooks.c b/src/test/modules/test_oat_hooks/test_oat_hooks.c index b1709f4d63..ed2c79652e 100644 --- a/src/test/modules/test_oat_hooks/test_oat_hooks.c +++ b/src/test/modules/test_oat_hooks/test_oat_hooks.c @@ -36,7 +36,6 @@ static bool REGRESS_audit = false; /* Saved hook values in case of unload */ static object_access_hook_type next_object_access_hook = NULL; static object_access_hook_type_str next_object_access_hook_str = NULL; -static ExecutorCheckPerms_hook_type next_exec_check_perms_hook = NULL; static ProcessUtility_hook_type next_ProcessUtility_hook = NULL; /* Test Object Access Type Hook hooks */ @@ -45,7 +44,6 @@ static void REGRESS_object_access_hook_str(ObjectAccessType access, int subId, void *arg); static void REGRESS_object_access_hook(ObjectAccessType access, Oid classId, Oid objectId, int subId, void *arg); -static bool REGRESS_exec_check_perms(List *rangeTabls, bool do_abort); static void REGRESS_utility_command(PlannedStmt *pstmt, const char *queryString, bool readOnlyTree, ProcessUtilityContext context, @@ -171,10 +169,6 @@ _PG_init(void) next_object_access_hook_str = object_access_hook_str; object_access_hook_str = REGRESS_object_access_hook_str; - /* DML permission check */ - next_exec_check_perms_hook = ExecutorCheckPerms_hook; - ExecutorCheckPerms_hook = REGRESS_exec_check_perms; - /* ProcessUtility hook */ next_ProcessUtility_hook = ProcessUtility_hook; ProcessUtility_hook = REGRESS_utility_command; @@ -190,9 +184,6 @@ _PG_fini(void) if (object_access_hook_str == REGRESS_object_access_hook_str) object_access_hook_str = next_object_access_hook_str; - if (ExecutorCheckPerms_hook == REGRESS_exec_check_perms) - ExecutorCheckPerms_hook = next_exec_check_perms_hook; - if (ProcessUtility_hook == REGRESS_utility_command) ProcessUtility_hook = next_ProcessUtility_hook; } @@ -232,12 +223,6 @@ audit_success(const char *hook, char *action, char *objName) emit_audit_message("finished", hook, action, objName); } -static void -audit_failure(const char *hook, char *action, char *objName) -{ - emit_audit_message("denied", hook, action, objName); -} - static void REGRESS_object_access_hook_str(ObjectAccessType access, Oid classId, const char *objName, int subId, void *arg) { @@ -302,38 +287,6 @@ REGRESS_object_access_hook (ObjectAccessType access, Oid classId, Oid objectId, accesstype_arg_to_string(access, arg)); } -static bool -REGRESS_exec_check_perms(List *rangeTabls, bool do_abort) -{ - bool am_super = superuser_arg(GetUserId()); - bool allow = true; - - audit_attempt("executor check perms", pstrdup("execute"), NULL); - - /* Perform our check */ - allow = !REGRESS_deny_exec_perms || am_super; - if (do_abort && !allow) - ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("permission denied: %s", "execute"))); - - /* Forward to next hook in the chain */ - if (next_exec_check_perms_hook && - !(*next_exec_check_perms_hook) (rangeTabls, do_abort)) - allow = false; - - if (allow) - audit_success("executor check perms", - pstrdup("execute"), - NULL); - else - audit_failure("executor check perms", - pstrdup("execute"), - NULL); - - return allow; -} - static void REGRESS_utility_command(PlannedStmt *pstmt, const char *queryString, -- 2.35.1 =

view thread (62+ messages)  latest in thread

Message-ID: <15D89996-7D4C-486C-9EB6-F0AC6AFEDDA2@enterprisedb.com>
Permalink:  ../15D89996-7D4C-486C-9EB6-F0AC6AFEDDA2@enterprisedb.com/
Also on:    postgresql.org/message-id/15D89996-7D4C-486C-9EB6-F0AC6AFEDDA2@enterprisedb.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: mark.dilger@enterprisedb.com, andrew@dunslane.net, tgl@sss.pgh.pa.us, rjuju123@gmail.com, joshua.brindle@crunchydata.com, robertmhaas@gmail.com, pgsql@j-davis.com, joe@crunchydata.com, sfrost@snowman.net
  Subject: Re: New Object Access Type hooks
  In-Reply-To: <15D89996-7D4C-486C-9EB6-F0AC6AFEDDA2@enterprisedb.com>
  References: <47F87A0E-C0E5-43A6-89F6-D403F2B45175@enterprisedb.com> <CAGB+Vh5PFQskeJDGCSBYMZHKDP9Wo6hLJ_=SnzE=SQwoXaToiA@mail.gmail.com> <E115F20B-87DF-4FB4-9D21-286D0CA70FA1@enterprisedb.com> <3ef3f6d7-b7b6-fb90-f3d0-afb1bf2a2cb9@dunslane.net> <516E8A9F-76AA-4C08-BDE6-259D62060D62@enterprisedb.com> <fdba7277-722b-a4ce-8027-88e4fc6ef0f8@dunslane.net> <448E56E1-0C59-441A-A6D0-66B8CFEFE540@enterprisedb.com> <7f6d54a1-4024-3b6e-e3ec-26cd394aac9e@dunslane.net> <20220322151444.pagugrb7rjmlee2z@jrouhaud> <AB996420-4E8B-4A8C-9752-F820FE11B913@enterprisedb.com> <f884a990-fd46-e809-86ca-2709d290cb57@dunslane.net> <2541365.1647964938@sss.pgh.pa.us> <75066591-7437-13b9-aaa0-7d7a4789700c@dunslane.net> <4420FCB6-16B2-4C28-B9A5-9C5A34A756CB@enterprisedb.com> <15D89996-7D4C-486C-9EB6-F0AC6AFEDDA2@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox