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

grant.test, grant.result, sql_acl.cc:

  BUG #5831 Changed mysql_revoke_all() to successfully delete all privileges for a user in one pass.
parent f5b7774e
...@@ -259,6 +259,26 @@ CREATE TABLE t7 LIKE t1; ...@@ -259,6 +259,26 @@ CREATE TABLE t7 LIKE t1;
CREATE TABLE t8 LIKE t1; CREATE TABLE t8 LIKE t1;
CREATE TABLE t9 LIKE t1; CREATE TABLE t9 LIKE t1;
CREATE TABLE t10 LIKE t1; CREATE TABLE t10 LIKE t1;
CREATE DATABASE testdb1;
CREATE DATABASE testdb2;
CREATE DATABASE testdb3;
CREATE DATABASE testdb4;
CREATE DATABASE testdb5;
CREATE DATABASE testdb6;
CREATE DATABASE testdb7;
CREATE DATABASE testdb8;
CREATE DATABASE testdb9;
CREATE DATABASE testdb10;
GRANT ALL ON testdb1.* TO testuser@localhost;
GRANT ALL ON testdb2.* TO testuser@localhost;
GRANT ALL ON testdb3.* TO testuser@localhost;
GRANT ALL ON testdb4.* TO testuser@localhost;
GRANT ALL ON testdb5.* TO testuser@localhost;
GRANT ALL ON testdb6.* TO testuser@localhost;
GRANT ALL ON testdb7.* TO testuser@localhost;
GRANT ALL ON testdb8.* TO testuser@localhost;
GRANT ALL ON testdb9.* TO testuser@localhost;
GRANT ALL ON testdb10.* TO testuser@localhost;
GRANT SELECT ON test.t1 TO testuser@localhost; GRANT SELECT ON test.t1 TO testuser@localhost;
GRANT SELECT ON test.t2 TO testuser@localhost; GRANT SELECT ON test.t2 TO testuser@localhost;
GRANT SELECT ON test.t3 TO testuser@localhost; GRANT SELECT ON test.t3 TO testuser@localhost;
...@@ -269,9 +289,29 @@ GRANT SELECT ON test.t7 TO testuser@localhost; ...@@ -269,9 +289,29 @@ GRANT SELECT ON test.t7 TO testuser@localhost;
GRANT SELECT ON test.t8 TO testuser@localhost; GRANT SELECT ON test.t8 TO testuser@localhost;
GRANT SELECT ON test.t9 TO testuser@localhost; GRANT SELECT ON test.t9 TO testuser@localhost;
GRANT SELECT ON test.t10 TO testuser@localhost; GRANT SELECT ON test.t10 TO testuser@localhost;
GRANT SELECT (a) ON test.t1 TO testuser@localhost;
GRANT SELECT (a) ON test.t2 TO testuser@localhost;
GRANT SELECT (a) ON test.t3 TO testuser@localhost;
GRANT SELECT (a) ON test.t4 TO testuser@localhost;
GRANT SELECT (a) ON test.t5 TO testuser@localhost;
GRANT SELECT (a) ON test.t6 TO testuser@localhost;
GRANT SELECT (a) ON test.t7 TO testuser@localhost;
GRANT SELECT (a) ON test.t8 TO testuser@localhost;
GRANT SELECT (a) ON test.t9 TO testuser@localhost;
GRANT SELECT (a) ON test.t10 TO testuser@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM testuser@localhost; REVOKE ALL PRIVILEGES, GRANT OPTION FROM testuser@localhost;
SHOW GRANTS FOR testuser@localhost; SHOW GRANTS FOR testuser@localhost;
Grants for testuser@localhost Grants for testuser@localhost
GRANT USAGE ON *.* TO 'testuser'@'localhost' GRANT USAGE ON *.* TO 'testuser'@'localhost'
DROP USER testuser@localhost; DROP USER testuser@localhost;
DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
DROP DATABASE testdb1;
DROP DATABASE testdb2;
DROP DATABASE testdb3;
DROP DATABASE testdb4;
DROP DATABASE testdb5;
DROP DATABASE testdb6;
DROP DATABASE testdb7;
DROP DATABASE testdb8;
DROP DATABASE testdb9;
DROP DATABASE testdb10;
...@@ -203,6 +203,26 @@ CREATE TABLE t7 LIKE t1; ...@@ -203,6 +203,26 @@ CREATE TABLE t7 LIKE t1;
CREATE TABLE t8 LIKE t1; CREATE TABLE t8 LIKE t1;
CREATE TABLE t9 LIKE t1; CREATE TABLE t9 LIKE t1;
CREATE TABLE t10 LIKE t1; CREATE TABLE t10 LIKE t1;
CREATE DATABASE testdb1;
CREATE DATABASE testdb2;
CREATE DATABASE testdb3;
CREATE DATABASE testdb4;
CREATE DATABASE testdb5;
CREATE DATABASE testdb6;
CREATE DATABASE testdb7;
CREATE DATABASE testdb8;
CREATE DATABASE testdb9;
CREATE DATABASE testdb10;
GRANT ALL ON testdb1.* TO testuser@localhost;
GRANT ALL ON testdb2.* TO testuser@localhost;
GRANT ALL ON testdb3.* TO testuser@localhost;
GRANT ALL ON testdb4.* TO testuser@localhost;
GRANT ALL ON testdb5.* TO testuser@localhost;
GRANT ALL ON testdb6.* TO testuser@localhost;
GRANT ALL ON testdb7.* TO testuser@localhost;
GRANT ALL ON testdb8.* TO testuser@localhost;
GRANT ALL ON testdb9.* TO testuser@localhost;
GRANT ALL ON testdb10.* TO testuser@localhost;
GRANT SELECT ON test.t1 TO testuser@localhost; GRANT SELECT ON test.t1 TO testuser@localhost;
GRANT SELECT ON test.t2 TO testuser@localhost; GRANT SELECT ON test.t2 TO testuser@localhost;
GRANT SELECT ON test.t3 TO testuser@localhost; GRANT SELECT ON test.t3 TO testuser@localhost;
...@@ -213,8 +233,28 @@ GRANT SELECT ON test.t7 TO testuser@localhost; ...@@ -213,8 +233,28 @@ GRANT SELECT ON test.t7 TO testuser@localhost;
GRANT SELECT ON test.t8 TO testuser@localhost; GRANT SELECT ON test.t8 TO testuser@localhost;
GRANT SELECT ON test.t9 TO testuser@localhost; GRANT SELECT ON test.t9 TO testuser@localhost;
GRANT SELECT ON test.t10 TO testuser@localhost; GRANT SELECT ON test.t10 TO testuser@localhost;
GRANT SELECT (a) ON test.t1 TO testuser@localhost;
GRANT SELECT (a) ON test.t2 TO testuser@localhost;
GRANT SELECT (a) ON test.t3 TO testuser@localhost;
GRANT SELECT (a) ON test.t4 TO testuser@localhost;
GRANT SELECT (a) ON test.t5 TO testuser@localhost;
GRANT SELECT (a) ON test.t6 TO testuser@localhost;
GRANT SELECT (a) ON test.t7 TO testuser@localhost;
GRANT SELECT (a) ON test.t8 TO testuser@localhost;
GRANT SELECT (a) ON test.t9 TO testuser@localhost;
GRANT SELECT (a) ON test.t10 TO testuser@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM testuser@localhost; REVOKE ALL PRIVILEGES, GRANT OPTION FROM testuser@localhost;
SHOW GRANTS FOR testuser@localhost; SHOW GRANTS FOR testuser@localhost;
DROP USER testuser@localhost; DROP USER testuser@localhost;
DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
DROP DATABASE testdb1;
DROP DATABASE testdb2;
DROP DATABASE testdb3;
DROP DATABASE testdb4;
DROP DATABASE testdb5;
DROP DATABASE testdb6;
DROP DATABASE testdb7;
DROP DATABASE testdb8;
DROP DATABASE testdb9;
DROP DATABASE testdb10;
...@@ -3636,13 +3636,10 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) ...@@ -3636,13 +3636,10 @@ 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; else
continue; continue;
} }
}
else
++counter; ++counter;
} }
...@@ -3666,9 +3663,9 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) ...@@ -3666,9 +3663,9 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list)
~0, 0, 1)) ~0, 0, 1))
{ {
result= -1; result= -1;
++counter;
continue;
} }
else
{
if (grant_table->cols) if (grant_table->cols)
{ {
List<LEX_COLUMN> columns; List<LEX_COLUMN> columns;
...@@ -3677,14 +3674,14 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) ...@@ -3677,14 +3674,14 @@ 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; else
continue; continue;
} }
else
continue;
} }
} }
else
++counter; ++counter;
} }
} }
......
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