From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 238BF288C1 for ; Mon, 11 Mar 2019 15:29:43 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hqcZ_znBIPlo for ; Mon, 11 Mar 2019 15:29:43 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 61D0628600 for ; Mon, 11 Mar 2019 15:29:42 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: [tarantool-patches] Re: [PATCH v2 2/9] box: fix _trigger and _ck_constraint access check From: "n.pettik" In-Reply-To: <3226bb82065bbaea578a909f5382571bbe01fa3b.1548838034.git.kshcherbatov@tarantool.org> Date: Mon, 11 Mar 2019 22:29:39 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <29CE984E-A6A6-4E1D-AFFD-721477BD73B1@tarantool.org> References: <3226bb82065bbaea578a909f5382571bbe01fa3b.1548838034.git.kshcherbatov@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Kirill Shcherbatov > src/box/alter.cc | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) >=20 > diff --git a/src/box/alter.cc b/src/box/alter.cc > index 0589c9678..ab3dd2e22 100644 > --- a/src/box/alter.cc > +++ b/src/box/alter.cc > @@ -3521,6 +3521,11 @@ on_replace_dd_trigger(struct trigger * /* = trigger */, void *event) > uint32_t space_id =3D > tuple_field_u32_xc(old_tuple, > BOX_TRIGGER_FIELD_SPACE_ID); > + struct space *space =3D space_by_id(space_id); > + assert(space !=3D NULL); > + access_check_ddl(space->def->name, space->def->id, > + space->def->uid, SC_SPACE, PRIV_A); Why did you check only alter privilege? On drop we should check drop privilege, on alter - alter privilege and on creation - creation privilege. This particular branch processes drop case, so we should use PRIV_D. > + > char *trigger_name =3D > (char *)region_alloc_xc(&fiber()->gc, > trigger_name_len + 1); > @@ -3574,6 +3579,10 @@ on_replace_dd_trigger(struct trigger * /* = trigger */, void *event) > "trigger space_id does not match the = value " > "resolved on AST building from SQL"); > } > + struct space *space =3D space_by_id(space_id); > + assert(space !=3D NULL); > + access_check_ddl(space->def->name, space->def->id, > + space->def->uid, SC_SPACE, PRIV_A); And PRIV_C depending on situation. The same for _fk_constraint space. > @@ -4018,6 +4031,10 @@ on_replace_dd_fk_constraint(struct trigger * /* = trigger*/, void *event) > space_cache_find_xc(fk_def->child_id); > struct space *parent_space =3D > space_cache_find_xc(fk_def->parent_id); > + access_check_ddl(child_space->def->name, = child_space->def->id, > + child_space->def->uid, SC_SPACE, = PRIV_A); > + access_check_ddl(parent_space->def->name, = parent_space->def->id, > + parent_space->def->uid, SC_SPACE, = PRIV_A); > struct fkey *old_fkey =3D > fkey_grab_by_name(&child_space->child_fkey, > fk_def->name); Please, add tests on these cases.