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 5E09C261C7 for ; Wed, 30 Jan 2019 03:59:20 -0500 (EST) 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 jWWDkjJpWgiA for ; Wed, 30 Jan 2019 03:59:20 -0500 (EST) Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (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 D744226190 for ; Wed, 30 Jan 2019 03:59:19 -0500 (EST) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v2 2/9] box: fix _trigger and _ck_constraint access check Date: Wed, 30 Jan 2019 11:59:09 +0300 Message-Id: <3226bb82065bbaea578a909f5382571bbe01fa3b.1548838034.git.kshcherbatov@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, korablev@tarantool.org Cc: Kirill Shcherbatov Fixed missed access checks for _trigger and _fk_constraint space. --- src/box/alter.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 = tuple_field_u32_xc(old_tuple, BOX_TRIGGER_FIELD_SPACE_ID); + struct space *space = space_by_id(space_id); + assert(space != NULL); + access_check_ddl(space->def->name, space->def->id, + space->def->uid, SC_SPACE, PRIV_A); + char *trigger_name = (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 = space_by_id(space_id); + assert(space != NULL); + access_check_ddl(space->def->name, space->def->id, + space->def->uid, SC_SPACE, PRIV_A); struct sql_trigger *old_trigger; if (sql_trigger_replace(trigger_name, @@ -3889,6 +3898,8 @@ on_replace_dd_fk_constraint(struct trigger * /* trigger*/, void *event) fk_def->name, "referencing space can't be VIEW"); } + access_check_ddl(child_space->def->name, child_space->def->id, + child_space->def->uid, SC_SPACE, PRIV_A); struct space *parent_space = space_cache_find_xc(fk_def->parent_id); if (parent_space->def->opts.is_view) { @@ -3896,6 +3907,8 @@ on_replace_dd_fk_constraint(struct trigger * /* trigger*/, void *event) fk_def->name, "referenced space can't be VIEW"); } + access_check_ddl(parent_space->def->name, parent_space->def->id, + parent_space->def->uid, SC_SPACE, PRIV_A); /* * FIXME: until SQL triggers are completely * integrated into server (i.e. we are able to @@ -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 = 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 = fkey_grab_by_name(&child_space->child_fkey, fk_def->name); -- 2.19.2