Commit 8a12b5ad authored by dellis@goetia.(none)'s avatar dellis@goetia.(none)

logging_ok:

  Logging to logging@openlogging.org accepted
sql_acl.cc, grant.test, grant.result:
  BUG 5831 Changed mysql_revoke_all() to successfully delete all privileges for a user in one pass.
parent 28f933fe
...@@ -34,6 +34,7 @@ brian@brian-akers-computer.local ...@@ -34,6 +34,7 @@ brian@brian-akers-computer.local
brian@private-client-ip-101.oz.net brian@private-client-ip-101.oz.net
carsten@tsort.bitbybit.dk carsten@tsort.bitbybit.dk
davida@isil.mysql.com davida@isil.mysql.com
dellis@goetia.(none)
dlenev@brandersnatch.localdomain dlenev@brandersnatch.localdomain
dlenev@build.mysql.com dlenev@build.mysql.com
dlenev@jabberwock.localdomain dlenev@jabberwock.localdomain
......
...@@ -248,3 +248,30 @@ GRANT SELECT ON `ab%`.* TO 'test11'@'localhost' ...@@ -248,3 +248,30 @@ GRANT SELECT ON `ab%`.* TO 'test11'@'localhost'
GRANT SELECT ON `a%`.* TO 'test11'@'localhost' GRANT SELECT ON `a%`.* TO 'test11'@'localhost'
delete from mysql.user where user='test11'; delete from mysql.user where user='test11';
delete from mysql.db where user='test11'; delete from mysql.db where user='test11';
USE test;
CREATE TABLE t1 (a int );
CREATE TABLE t2 LIKE t1;
CREATE TABLE t3 LIKE t1;
CREATE TABLE t4 LIKE t1;
CREATE TABLE t5 LIKE t1;
CREATE TABLE t6 LIKE t1;
CREATE TABLE t7 LIKE t1;
CREATE TABLE t8 LIKE t1;
CREATE TABLE t9 LIKE t1;
CREATE TABLE t10 LIKE t1;
GRANT SELECT ON test.t1 TO testuser@localhost;
GRANT SELECT ON test.t2 TO testuser@localhost;
GRANT SELECT ON test.t3 TO testuser@localhost;
GRANT SELECT ON test.t4 TO testuser@localhost;
GRANT SELECT ON test.t5 TO testuser@localhost;
GRANT SELECT ON test.t6 TO testuser@localhost;
GRANT SELECT ON test.t7 TO testuser@localhost;
GRANT SELECT ON test.t8 TO testuser@localhost;
GRANT SELECT ON test.t9 TO testuser@localhost;
GRANT SELECT ON test.t10 TO testuser@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM testuser@localhost;
SHOW GRANTS FOR testuser@localhost;
Grants for testuser@localhost
GRANT USAGE ON *.* TO 'testuser'@'localhost'
DROP USER testuser@localhost;
DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
...@@ -189,3 +189,32 @@ show grants for test11@localhost; ...@@ -189,3 +189,32 @@ show grants for test11@localhost;
delete from mysql.user where user='test11'; delete from mysql.user where user='test11';
delete from mysql.db where user='test11'; delete from mysql.db where user='test11';
#
# Bug #5831: REVOKE ALL PRIVILEGES, GRANT OPTION does not revoke everything
#
USE test;
CREATE TABLE t1 (a int );
CREATE TABLE t2 LIKE t1;
CREATE TABLE t3 LIKE t1;
CREATE TABLE t4 LIKE t1;
CREATE TABLE t5 LIKE t1;
CREATE TABLE t6 LIKE t1;
CREATE TABLE t7 LIKE t1;
CREATE TABLE t8 LIKE t1;
CREATE TABLE t9 LIKE t1;
CREATE TABLE t10 LIKE t1;
GRANT SELECT ON test.t1 TO testuser@localhost;
GRANT SELECT ON test.t2 TO testuser@localhost;
GRANT SELECT ON test.t3 TO testuser@localhost;
GRANT SELECT ON test.t4 TO testuser@localhost;
GRANT SELECT ON test.t5 TO testuser@localhost;
GRANT SELECT ON test.t6 TO testuser@localhost;
GRANT SELECT ON test.t7 TO testuser@localhost;
GRANT SELECT ON test.t8 TO testuser@localhost;
GRANT SELECT ON test.t9 TO testuser@localhost;
GRANT SELECT ON test.t10 TO testuser@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM testuser@localhost;
SHOW GRANTS FOR testuser@localhost;
DROP USER testuser@localhost;
DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
...@@ -3622,7 +3622,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) ...@@ -3622,7 +3622,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list)
} }
/* Remove db access privileges */ /* Remove db access privileges */
for (counter= 0 ; counter < acl_dbs.elements ; counter++) for (counter= 0 ; counter < acl_dbs.elements ; )
{ {
const char *user,*host; const char *user,*host;
...@@ -3636,12 +3636,18 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) ...@@ -3636,12 +3636,18 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list)
!my_strcasecmp(system_charset_info, lex_user->host.str, host)) !my_strcasecmp(system_charset_info, lex_user->host.str, host))
{ {
if (replace_db_table(tables[1].table, acl_db->db, *lex_user, ~0, 1)) if (replace_db_table(tables[1].table, acl_db->db, *lex_user, ~0, 1))
{
result= -1; result= -1;
++counter;
continue;
} }
} }
else
++counter;
}
/* Remove column access */ /* Remove column access */
for (counter= 0 ; counter < column_priv_hash.records ; counter++) for (counter= 0 ; counter < column_priv_hash.records ; )
{ {
const char *user,*host; const char *user,*host;
GRANT_TABLE *grant_table= (GRANT_TABLE*) hash_element(&column_priv_hash, GRANT_TABLE *grant_table= (GRANT_TABLE*) hash_element(&column_priv_hash,
...@@ -3660,6 +3666,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) ...@@ -3660,6 +3666,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list)
~0, 0, 1)) ~0, 0, 1))
{ {
result= -1; result= -1;
++counter;
continue; continue;
} }
if (grant_table->cols) if (grant_table->cols)
...@@ -3670,10 +3677,16 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) ...@@ -3670,10 +3677,16 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list)
grant_table->db, grant_table->db,
grant_table->tname, grant_table->tname,
~0, 1)) ~0, 1))
{
result= -1; result= -1;
++counter;
continue;
} }
} }
} }
else
++counter;
}
} }
VOID(pthread_mutex_unlock(&acl_cache->lock)); VOID(pthread_mutex_unlock(&acl_cache->lock));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment