Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.1.44, 10.2.31, 10.3.22, 10.4.12, 10.5.2
-
None
Description
Let's say that we create a role and a user account:
MariaDB [(none)]> CREATE ROLE 'test_role'; |
Query OK, 0 rows affected (0.004 sec) |
|
MariaDB [(none)]> CREATE USER 'test_user'@'%'; |
Query OK, 0 rows affected (0.004 sec) |
And then let's say that we set this role to be the default role for the user account:
MariaDB [(none)]> GRANT 'test_role' TO 'test_user'@'%'; |
Query OK, 0 rows affected (0.004 sec) |
|
MariaDB [(none)]> SET DEFAULT ROLE 'test_role' FOR 'test_user'@'%'; |
Query OK, 0 rows affected (0.004 sec) |
Neither SHOW CREATE USER now SHOW GRANTS prints this default role for the user account:
MariaDB [(none)]> SHOW CREATE USER 'test_user'@'%'; |
+-----------------------------+ |
| CREATE USER for test_user@% | |
+-----------------------------+ |
| CREATE USER 'test_user'@'%' | |
+-----------------------------+ |
1 row in set (0.000 sec) |
|
MariaDB [(none)]> SHOW GRANTS FOR 'test_user'@'%'; |
+---------------------------------------+ |
| Grants for test_user@% | |
+---------------------------------------+ |
| GRANT test_role TO 'test_user'@'%' | |
| GRANT USAGE ON *.* TO 'test_user'@'%' | |
+---------------------------------------+ |
2 rows in set (0.000 sec) |
In my opinion, it should at least be printed by SHOW GRANTS, since it is somewhat related to one of the grants that is printed.
Attachments
Issue Links
- relates to
-
MDEV-23630 mysqldump to logically dump system tables
-
- Closed
-
-
MDEV-26080 SHOW GRANTS does not quote role names properly for DEFAULT ROLE
-
- Closed
-
-
MDEV-22311 implement SHOW CREATE ROLE
-
- Open
-
-
MDEV-22312 Bad error message for SET DEFAULT ROLE when user account is not granted the role
-
- Closed
-
Hi serg,
what I have seen that DEFALT_ROLE doesn't get set after all grants for root.
Here is an example:
SET DEFAULT ROLE test_role; #order doesn't matter
+SET ROLE test_role;
SHOW GRANTS;
Grants for root@localhost
GRANT test_role TO 'root'@'localhost' WITH ADMIN OPTION
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION
SET DEFAULT ROLE test_role FOR 'root'@'localhost' #this line should be last line?
+GRANT USAGE ON *.* TO 'test_role'
I guess I need to change this?
If the check for default_role is validated after rolename check:
if (rolename)
@@ -8801,6 +8796,10 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user)
}
}
+ /* Show default role to acl_user */
+ if (show_default_role(thd, acl_user, buff, sizeof(buff)))
+ goto end;
+
Grants for test_user@%
GRANT test_role TO 'test_user'@'%'
GRANT USAGE ON *.* TO 'test_user'@'%'
+SET ROLE test_role;
SET DEFAULT ROLE test_role;
SHOW GRANTS;
Grants for root@localhost
GRANT test_role TO 'root'@'localhost' WITH ADMIN OPTION
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION
+GRANT USAGE ON *.* TO 'test_role'
SET DEFAULT ROLE test_role FOR 'root'@'localhost' #now it is the last line
SET DEFAULT ROLE NONE;
SHOW GRANTS;
So this is done on the new 10.2 commit (again local repo):
https://github.com/an3l/server/commit/2e0bac4688a73cd6df406727ce7f6c62a57b7293
Thanks for few review iterations.