[MDEV-6295] grant ... with grant option using wildcards including \_ Created: 2014-06-02  Updated: 2014-06-03  Resolved: 2014-06-03

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.11-galera
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Christian Quast Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

When granting privileges on a set of databases using wildcards including '\_' with 'grant option' to a user this user may create new databases according to the pattern but cannot grant privileges to other users.

Excerpt from http://dev.mysql.com/doc/refman/5.5/en/grant.html:

The “” and “%” wildcards are permitted when specifying database names in GRANT statements that grant privileges at the global or database levels. This means, for example, that if you want to use a “” character as part of a database name, you should specify it as “_” in the GRANT statement, to prevent the user from being able to access additional databases matching the wildcard pattern; for example, GRANT ... ON `foo_bar`.* TO

So when executing as root/admin user

grant all on `%\_bar` to user with grant option

I would expect the user to be able to create a database foo_bar (which works just fine) and then be able to grant privileges to other users. Instead an access denied error is reported ERROR 1044 (42000): Access denied for user 'user'@'%' to database 'foo_bar'

When I change the db pattern to '%_bar', granting privileges works as expected.

Logged in as admin user:

grant all on `%_bar` to user with grant option

Logged in as 'user'

MariaDB [none]> create database foo_bar;
Query OK, 1 row affected (0.00 sec)
MariaDB [none]> grant all on foo_bar.* to otheruser;
Query OK, 0 rows affected (0.00 sec)

After this 'otheruser' can work with database foo_bar. However, this workaround will allow 'user' to create databases such as 'abar' which is not intended.



 Comments   
Comment by Elena Stepanova [ 2014-06-03 ]

Hi,

This is an ancient not-a-bug http://bugs.mysql.com/bug.php?id=12008.
The last comment in that bug report contains an explanation.
What you need to run as a `user` is

 
grant all on `foo\_bar`.* to otheruser;

Generated at Thu Feb 08 07:10:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.