diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2017-10-09 13:32:40 +0300 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2017-10-11 12:15:52 +0300 |
commit | b9418ed3332358e7209300739435c5e0aeb5ba70 (patch) | |
tree | d2579cc902b3507f8ea964ca7e907e5652ed2c1d /sql/sp_head.cc | |
parent | fc9ff69578fa8c3d818d6eaaa171b4be49d70814 (diff) | |
download | mariadb-git-b9418ed3332358e7209300739435c5e0aeb5ba70.tar.gz |
MDEV-13676: Field "create Procedure" is NULL, even if the the user has role which is the definer. (SHOW CREATE PROCEDURE)
During show create procedure we ommited to check the current role, if it
is the actual definer of the procedure. In addition, we should support
indirectly granted roles to the current role. Implemented a recursive
lookup to search the tree of grants if the rolename is present.
SQL Standard 2016, Part 5 Section 53 View I_S.ROUTINES selects
ROUTINE_BODY and its WHERE clause says that the GRANTEE must be
either PUBLIC, or CURRENT_USER or in the ENABLED_ROLES.
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r-- | sql/sp_head.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index ea9e1c1c822..3dd1a65ff83 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -2588,10 +2588,18 @@ bool check_show_routine_access(THD *thd, sp_head *sp, bool *full_access) *full_access= ((!check_table_access(thd, SELECT_ACL, &tables, FALSE, 1, TRUE) && (tables.grant.privilege & SELECT_ACL) != 0) || + /* Check if user owns the routine. */ (!strcmp(sp->m_definer_user.str, thd->security_ctx->priv_user) && !strcmp(sp->m_definer_host.str, - thd->security_ctx->priv_host))); + thd->security_ctx->priv_host)) || + /* Check if current role or any of the sub-granted roles + own the routine. */ + (sp->m_definer_host.length == 0 && + (!strcmp(sp->m_definer_user.str, + thd->security_ctx->priv_role) || + check_role_is_granted(thd->security_ctx->priv_role, NULL, + sp->m_definer_user.str)))); if (!*full_access) return check_some_routine_access(thd, sp->m_db.str, sp->m_name.str, sp->m_type == TYPE_ENUM_PROCEDURE); |