summaryrefslogtreecommitdiff
path: root/sql/sql_acl.cc
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <cvicentiu@gmail.com>2022-09-12 10:44:12 +0300
committerVicențiu-Marian Ciorbaru <vicentiu@mariadb.org>2022-09-14 14:40:50 +0300
commit16b2bb909adeae8c2be628112a5c28f1618145dc (patch)
tree38e6d036e64e210f960f0738244a7cb6462c98da /sql/sql_acl.cc
parent5ad8cd93b7a00100ee2166d39e58ca240cc7398c (diff)
downloadmariadb-git-16b2bb909adeae8c2be628112a5c28f1618145dc.tar.gz
MDEV-29509 execute granted indirectly (via roles) doesn't always work
The issue manifests due to a bug in mysql_routine_grant. This was a side effect of e46eea8660fb which fixed the problem of not giving appropriate error message (ER_NONEXISTING_PROC_GRANT) when a routine grant existed due to role inheritance. When granting a routine privilege, it is possible to have a GRANT_NAME entry already created from an inherited role, but with it's init_privs set to 0. In this case we must not create a *new* grant entry, but we must edit this grant entry to set its init_privs. Note that this case was already covered by MDEV-29458, however due to a forgotten "flush privileges;" the actual code path never got hit. Remove the flush privilege command as it was never intended to be there in the first place.
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r--sql/sql_acl.cc25
1 files changed, 13 insertions, 12 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 31e0f64e6dc..0110a1f0c65 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -6793,23 +6793,24 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list,
table_name= table_list->table_name.str;
grant_name= routine_hash_search(Str->host.str, NullS, db_name,
Str->user.str, table_name, sph, 1);
- if (!grant_name || !grant_name->init_privs)
+ if (revoke_grant && (!grant_name || !grant_name->init_privs))
{
- if (revoke_grant)
- {
- my_error(ER_NONEXISTING_PROC_GRANT, MYF(0),
- Str->user.str, Str->host.str, table_name);
- result= TRUE;
- continue;
- }
+ my_error(ER_NONEXISTING_PROC_GRANT, MYF(0),
+ Str->user.str, Str->host.str, table_name);
+ result= TRUE;
+ continue;
+ }
+ if (!grant_name)
+ {
+ DBUG_ASSERT(!revoke_grant);
grant_name= new GRANT_NAME(Str->host.str, db_name,
- Str->user.str, table_name,
- rights, TRUE);
+ Str->user.str, table_name,
+ rights, TRUE);
if (!grant_name ||
- my_hash_insert(sph->get_priv_hash(), (uchar*) grant_name))
+ my_hash_insert(sph->get_priv_hash(), (uchar*) grant_name))
{
result= TRUE;
- continue;
+ continue;
}
}