Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id A1FFA6331ED for ; Wed, 30 Sep 2009 02:39:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 24655-07 for ; Wed, 30 Sep 2009 05:39:43 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tyo202.gate.nec.co.jp (TYO202.gate.nec.co.jp [202.32.8.206]) by mail.postgresql.org (Postfix) with ESMTP id 9B03263312A for ; Wed, 30 Sep 2009 02:39:38 -0300 (ADT) Received: from mailgate3.nec.co.jp ([10.7.69.197]) by tyo202.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id n8U5dV3e028769; Wed, 30 Sep 2009 14:39:31 +0900 (JST) Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id n8U5dVw28367; Wed, 30 Sep 2009 14:39:31 +0900 (JST) Received: from mail03.kamome.nec.co.jp (mail03.kamome.nec.co.jp [10.25.43.7]) by mailsv3.nec.co.jp (8.13.8/8.13.4) with ESMTP id n8U5dU3r000148; Wed, 30 Sep 2009 14:39:30 +0900 (JST) Received: from saigo.jp.nec.com ([10.26.220.6] [10.26.220.6]) by mail03.kamome.nec.co.jp with ESMTP id BT-MMP-2259842; Wed, 30 Sep 2009 14:32:36 +0900 Received: from [10.19.71.82] ([10.19.71.82] [10.19.71.82]) by mail.jp.nec.com with ESMTP; Wed, 30 Sep 2009 14:32:36 +0900 Message-ID: <4AC2ED74.2030409@ak.jp.nec.com> Date: Wed, 30 Sep 2009 14:32:36 +0900 From: KaiGai Kohei User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Stephen Frost CC: KaiGai Kohei , Robert Haas , pgsql-hackers@postgresql.org Subject: Re: [PATCH] Reworks for Access Control facilities (r2311) References: <20090929105431.GO17756@tamriel.snowman.net> <4AC1EA9E.3080907@kaigai.gr.jp> <20090929173049.GP17756@tamriel.snowman.net> <4AC2BDD0.7050906@ak.jp.nec.com> In-Reply-To: <4AC2BDD0.7050906@ak.jp.nec.com> Content-Type: multipart/mixed; boundary="------------010401070004010201060007" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.516 tagged_above=-10 required=5 tests=BAYES_00=-2.599, URIBL_RHS_DOB=1.083 X-Spam-Level: X-Archive-Number: 200909/1923 X-Sequence-Number: 146729 This is a multi-part message in MIME format. --------------010401070004010201060007 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit >>>>> I don't find the comment regarding what happened with FindConversion to >>>>> be nearly descriptive enough. Can you elaborate on why the check wasn't >>>>> necessary and has now been removed? If it really isn't needed, why have >>>>> that function at all? >>> http://archives.postgresql.org/message-id/26499.1250706473@sss.pgh.pa.us >>> >>> I'll add a comment about the reason why this check was simply eliminated. >> Could these kind of changes be done as a separate patch? Perhaps one >> which should be applied first? It's alot easier to review if we can >> have: >> >> - patches to fix things in PG (such as the above) >> - patch to add in ac_* model > > I think we can apply these kind of eliminations earlier or later. > These checks might be redundant or unnecessary, but harmless. > As far as the reworks patch does not touch them, it does not affect > to our discussion. The attached patch eliminates permission checks in FindConversion() and EnableDisableRule(), because these are nonsense or redundant. It is an separated issue from the ac_*() routines. For now, we decided not to touch these stuffs in the access control reworks patch. So, we can discuss about these fixes as a different topic. See the corresponding messages: http://archives.postgresql.org/message-id/26499.1250706473@sss.pgh.pa.us http://archives.postgresql.org/message-id/4ABC136A.90903@ak.jp.nec.com Thanks, -- OSS Platform Development Division, NEC KaiGai Kohei --------------010401070004010201060007 Content-Type: text/x-patch; name="remove-unneeded-checks.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="remove-unneeded-checks.patch" Index: base/src/backend/rewrite/rewriteDefine.c =================================================================== *** base/src/backend/rewrite/rewriteDefine.c (revision 2336) --- base/src/backend/rewrite/rewriteDefine.c (working copy) *************** EnableDisableRule(Relation rel, const ch *** 671,677 **** { Relation pg_rewrite_desc; Oid owningRel = RelationGetRelid(rel); - Oid eventRelationOid; HeapTuple ruletup; bool changed = false; --- 671,676 ---- *************** EnableDisableRule(Relation rel, const ch *** 690,702 **** rulename, get_rel_name(owningRel)))); /* ! * Verify that the user has appropriate permissions. */ - eventRelationOid = ((Form_pg_rewrite) GETSTRUCT(ruletup))->ev_class; - Assert(eventRelationOid == owningRel); - if (!pg_class_ownercheck(eventRelationOid, GetUserId())) - aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS, - get_rel_name(eventRelationOid)); /* * Change ev_enabled if it is different from the desired new state. --- 689,704 ---- rulename, get_rel_name(owningRel)))); /* ! * At the prior release, we had a permission check here on ! * a relation on which the given rule is configured. ! * If user does not have ownership on the relation, it raises ! * an error and aborts current transaction. ! * But this check was redundant. ATExecCmd() is the only caller ! * of EnableDisableRule(), and ATPrepCmd() already checks ! * ownership of the target relation ATSimplePermissions(). ! * ! * Therefore, we removed this permission check at v8.5. */ /* * Change ev_enabled if it is different from the desired new state. Index: base/src/backend/catalog/pg_conversion.c =================================================================== *** base/src/backend/catalog/pg_conversion.c (revision 2336) --- base/src/backend/catalog/pg_conversion.c (working copy) *************** *** 24,30 **** #include "catalog/pg_proc.h" #include "mb/pg_wchar.h" #include "miscadmin.h" - #include "utils/acl.h" #include "utils/builtins.h" #include "utils/fmgroids.h" #include "utils/rel.h" --- 24,29 ---- *************** FindDefaultConversion(Oid name_space, in *** 219,246 **** Oid FindConversion(const char *conname, Oid connamespace) { ! HeapTuple tuple; ! Oid procoid; ! Oid conoid; ! AclResult aclresult; ! ! /* search pg_conversion by connamespace and conversion name */ ! tuple = SearchSysCache(CONNAMENSP, ! PointerGetDatum(conname), ! ObjectIdGetDatum(connamespace), ! 0, 0); ! if (!HeapTupleIsValid(tuple)) ! return InvalidOid; ! ! procoid = ((Form_pg_conversion) GETSTRUCT(tuple))->conproc; ! conoid = HeapTupleGetOid(tuple); ! ! ReleaseSysCache(tuple); ! ! /* Check we have execute rights for the function */ ! aclresult = pg_proc_aclcheck(procoid, GetUserId(), ACL_EXECUTE); ! if (aclresult != ACLCHECK_OK) ! return InvalidOid; ! ! return conoid; } --- 218,237 ---- Oid FindConversion(const char *conname, Oid connamespace) { ! /* ! * At the prior release, we had a permission check here ! * on the conversion function. If user does not have ! * ACL_EXECUTE right on the function, the caller performs ! * as if the required conversion is not exist. ! * However, it is nonsense. FindConversion() is only called ! * from the DDL code patch, such as ALTER CONVERSION, so ! * we already apply enough checks on its creation time, and ! * no interfaces are provided to change conversion function. ! * ! * Therefore, we removed this permission check at v8.5. ! */ ! return GetSysCacheOid(CONNAMENSP, ! PointerGetDatum(conname), ! ObjectIdGetDatum(connamespace), ! 0, 0); } --------------010401070004010201060007--