Skip to content

Commit 22491e6

Browse files
committed
MDEV-30154: Assertion `strcasecmp(rolename, public_name.str) || acl_public == role' failed in acl_update_role on GRANT ... TO PUBLIC
Reset of acl_public was made too early (before saving it to restore in case of error).
1 parent a5be6c9 commit 22491e6

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

mysql-test/main/public_basic.result

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,23 @@ delete from mysql.global_priv where user="PUBLIC";
100100
flush privileges;
101101
grant execute on procedure mtr.add_suppression to public;
102102
revoke execute on procedure mtr.add_suppression from public;
103+
#
104+
# MDEV-30154: Assertion `strcasecmp(rolename, public_name.str) ||
105+
# acl_public == role' failed in acl_update_role on GRANT ... TO PUBLIC
106+
#
107+
call mtr.add_suppression("Can't open and lock privilege tables");
108+
USE test;
109+
GRANT SELECT ON *.* TO PUBLIC;
110+
LOCK TABLES mysql.time_zone WRITE,mysql.proc WRITE;
111+
FLUSH PRIVILEGES;
112+
ERROR HY000: Table 'db' was not locked with LOCK TABLES
113+
LOCK TABLE nonexisting WRITE;
114+
ERROR 42S02: Table 'test.nonexisting' doesn't exist
115+
GRANT SELECT ON *.* TO PUBLIC;
116+
REVOKE SELECT ON *.* FROM PUBLIC;
117+
#
118+
# End of 10.11 test
119+
#
103120
# clean up
104121
delete from mysql.global_priv where user="PUBLIC";
105122
flush privileges;

mysql-test/main/public_basic.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,26 @@ flush privileges;
109109
grant execute on procedure mtr.add_suppression to public;
110110
revoke execute on procedure mtr.add_suppression from public;
111111

112+
--echo #
113+
--echo # MDEV-30154: Assertion `strcasecmp(rolename, public_name.str) ||
114+
--echo # acl_public == role' failed in acl_update_role on GRANT ... TO PUBLIC
115+
--echo #
116+
call mtr.add_suppression("Can't open and lock privilege tables");
117+
USE test;
118+
GRANT SELECT ON *.* TO PUBLIC;
119+
LOCK TABLES mysql.time_zone WRITE,mysql.proc WRITE;
120+
--error 1100
121+
FLUSH PRIVILEGES;
122+
--error 1146
123+
LOCK TABLE nonexisting WRITE;
124+
GRANT SELECT ON *.* TO PUBLIC;
125+
126+
REVOKE SELECT ON *.* FROM PUBLIC;
127+
128+
--echo #
129+
--echo # End of 10.11 test
130+
--echo #
131+
112132
-- echo # clean up
113133
delete from mysql.global_priv where user="PUBLIC";
114134
flush privileges;

sql/sql_acl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2918,7 +2918,6 @@ bool acl_reload(THD *thd)
29182918
int result;
29192919
DBUG_ENTER("acl_reload");
29202920

2921-
acl_public= NULL;
29222921

29232922
Grant_tables tables;
29242923
/*
@@ -2963,6 +2962,7 @@ bool acl_reload(THD *thd)
29632962
old_mem= acl_memroot;
29642963
delete_dynamic(&acl_wild_hosts);
29652964
my_hash_free(&acl_check_hosts);
2965+
acl_public= NULL;
29662966

29672967
if ((result= acl_load(thd, tables)))
29682968
{ // Error. Revert to old list

0 commit comments

Comments
 (0)