Skip to content

Commit

Permalink
Merge pull request #18 from vlad-lesin/5.6-ps-bug-1354988
Browse files Browse the repository at this point in the history
5.6 ps bug 1354988
  • Loading branch information
laurynas-biveinis committed Feb 25, 2015
2 parents e7c574e + ee931c3 commit 42f275a
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 3 deletions.
13 changes: 13 additions & 0 deletions mysql-test/r/grant.result
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ show grants for mysqltest1@'192.%';
Grants for mysqltest1@192.%
GRANT USAGE ON *.* TO 'mysqltest1'@'192.%'
GRANT SELECT ON `mysqltest`.`t1` TO 'mysqltest1'@'192.%'
GRANT DELETE ON `mysqltest`.`t1` TO 'mysqltest1'@'%'
show grants for mysqltest1@'%';
Grants for mysqltest1@%
GRANT USAGE ON *.* TO 'mysqltest1'@'%'
Expand Down Expand Up @@ -836,6 +837,7 @@ show grants for mysqltest_8;
Grants for mysqltest_8@%
GRANT USAGE ON *.* TO 'mysqltest_8'@'%'
GRANT SELECT ON `mysqltest`.* TO 'mysqltest_8'@'%'
GRANT SELECT ON `mysqltest`.* TO 'mysqltest_8'@''
select * from information_schema.schema_privileges
where grantee like "'mysqltest_8'%";
GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
Expand Down Expand Up @@ -875,6 +877,7 @@ grant update (a) on t1 to mysqltest_8;
show grants for mysqltest_8@'';
Grants for mysqltest_8@
GRANT USAGE ON *.* TO 'mysqltest_8'@''
GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'%'
GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@''
show grants for mysqltest_8;
Grants for mysqltest_8@%
Expand All @@ -884,11 +887,13 @@ flush privileges;
show grants for mysqltest_8@'';
Grants for mysqltest_8@
GRANT USAGE ON *.* TO 'mysqltest_8'@''
GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'%'
GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@''
show grants for mysqltest_8;
Grants for mysqltest_8@%
GRANT USAGE ON *.* TO 'mysqltest_8'@'%'
GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'%'
GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@''
select * from information_schema.column_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_8'@'%' def test t1 a UPDATE NO
Expand Down Expand Up @@ -918,6 +923,7 @@ grant update on t1 to mysqltest_8;
show grants for mysqltest_8@'';
Grants for mysqltest_8@
GRANT USAGE ON *.* TO 'mysqltest_8'@''
GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@'%'
GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@''
show grants for mysqltest_8;
Grants for mysqltest_8@%
Expand All @@ -927,11 +933,13 @@ flush privileges;
show grants for mysqltest_8@'';
Grants for mysqltest_8@
GRANT USAGE ON *.* TO 'mysqltest_8'@''
GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@'%'
GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@''
show grants for mysqltest_8;
Grants for mysqltest_8@%
GRANT USAGE ON *.* TO 'mysqltest_8'@'%'
GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@'%'
GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@''
select * from information_schema.table_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_8'@'%' def test t1 UPDATE NO
Expand Down Expand Up @@ -964,12 +972,14 @@ grant all privileges on mysqltest.* to mysqltest_8;
show grants for mysqltest_8@'';
Grants for mysqltest_8@
GRANT USAGE ON *.* TO 'mysqltest_8'@''
GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'%'
GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@''
GRANT UPDATE, UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@''
show grants for mysqltest_8;
Grants for mysqltest_8@%
GRANT USAGE ON *.* TO 'mysqltest_8'@'%'
GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'%'
GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@''
select * from information_schema.user_privileges
where grantee like "'mysqltest_8'%";
GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
Expand All @@ -982,12 +992,15 @@ flush privileges;
show grants for mysqltest_8@'';
Grants for mysqltest_8@
GRANT USAGE ON *.* TO 'mysqltest_8'@''
GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'%'
GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@''
GRANT UPDATE, UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@''
show grants for mysqltest_8;
Grants for mysqltest_8@%
GRANT USAGE ON *.* TO 'mysqltest_8'@'%'
GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'%'
GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@''
GRANT UPDATE, UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@''
drop user mysqltest_8@'';
show grants for mysqltest_8@'';
ERROR 42000: There is no such grant defined for user 'mysqltest_8' on host ''
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/r/grant_cache.result
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ Qcache_not_cached 1
show grants for current_user();
Grants for @localhost
GRANT USAGE ON *.* TO ''@'localhost'
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, EVENT, TRIGGER ON `test`.* TO ''@'%'
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, EVENT, TRIGGER ON `test\_%`.* TO ''@'%'
----- establish connection user2 (user=mysqltest_2) -----
select "user2";
user2
Expand Down
50 changes: 50 additions & 0 deletions mysql-test/r/percona_bug1354988.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
CREATE USER grantee@localhost IDENTIFIED BY 'grantee1';
CREATE USER grantee IDENTIFIED BY 'grantee2';
CREATE DATABASE db2;
CREATE DATABASE db3;
USE db3;
CREATE TABLE t1 (a INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b INT(10) UNSIGNED NOT NULL DEFAULT 0);
CREATE TABLE t2 (a INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b INT(10) UNSIGNED NOT NULL DEFAULT 0);
INSERT INTO t2 (b) VALUES (1), (2);
CREATE FUNCTION f1() RETURNS INT
BEGIN
RETURN 1;
END |
CREATE PROCEDURE p1()
BEGIN
SELECT 1;
END |
GRANT ALL PRIVILEGES ON db2.* TO grantee WITH GRANT OPTION;
GRANT SELECT(a) ON TABLE db3.t2 TO grantee WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON TABLE db3.t1 TO grantee WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON FUNCTION db3.f1 TO grantee WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON PROCEDURE db3.p1 TO grantee WITH GRANT OPTION;
SELECT user(), current_user();
user() current_user()
grantee@localhost grantee@localhost
SHOW GRANTS;
Grants for grantee@localhost
GRANT USAGE ON *.* TO 'grantee'@'localhost' IDENTIFIED BY PASSWORD '*9823FF338D44DAF02422CF24DD1F879FB4F6B232'
GRANT ALL PRIVILEGES ON `db2`.* TO 'grantee'@'%' WITH GRANT OPTION
GRANT SELECT (a) ON `db3`.`t2` TO 'grantee'@'%' WITH GRANT OPTION
GRANT ALL PRIVILEGES ON `db3`.`t1` TO 'grantee'@'%' WITH GRANT OPTION
GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `db3`.`p1` TO 'grantee'@'%' WITH GRANT OPTION
GRANT EXECUTE, ALTER ROUTINE ON FUNCTION `db3`.`f1` TO 'grantee'@'%' WITH GRANT OPTION
USE db2;
CREATE TABLE t1(f1 int);
USE db3;
SELECT a FROM t2;
a
1
2
INSERT INTO t1 (b) VALUES (1), (2);
SELECT f1();
f1()
1
CALL p1();
1
1
DROP DATABASE db2;
DROP DATABASE db3;
DROP USER grantee@localhost;
DROP USER grantee;
4 changes: 4 additions & 0 deletions mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ SHOW/SELECT shows all processes/threads.
SHOW GRANTS;
Grants for @localhost
GRANT PROCESS ON *.* TO ''@'localhost'
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, EVENT, TRIGGER ON `test`.* TO ''@'%'
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, EVENT, TRIGGER ON `test\_%`.* TO ''@'%'
SHOW processlist;
Id User Host db Command Time State Info Rows_sent Rows_examined
ID HOST_NAME information_schema Query TIME init SHOW processlist TIME_MS 0
Expand Down Expand Up @@ -257,6 +259,8 @@ Again only the processes of the anonymous user are visible.
SHOW GRANTS FOR ''@'localhost';
Grants for @localhost
GRANT USAGE ON *.* TO ''@'localhost'
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, EVENT, TRIGGER ON `test`.* TO ''@'%'
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, EVENT, TRIGGER ON `test\_%`.* TO ''@'%'
SELECT * FROM information_schema.processlist;
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS ROWS_SENT ROWS_EXAMINED
ID HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0
Expand Down
53 changes: 53 additions & 0 deletions mysql-test/t/percona_bug1354988.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# The bug #1354988 test.

CREATE USER grantee@localhost IDENTIFIED BY 'grantee1';
CREATE USER grantee IDENTIFIED BY 'grantee2';

CREATE DATABASE db2;


CREATE DATABASE db3;
USE db3;

CREATE TABLE t1 (a INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b INT(10) UNSIGNED NOT NULL DEFAULT 0);
CREATE TABLE t2 (a INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b INT(10) UNSIGNED NOT NULL DEFAULT 0);
INSERT INTO t2 (b) VALUES (1), (2);

-- delimiter |

CREATE FUNCTION f1() RETURNS INT
BEGIN
RETURN 1;
END |

CREATE PROCEDURE p1()
BEGIN
SELECT 1;
END |

-- delimiter ;

GRANT ALL PRIVILEGES ON db2.* TO grantee WITH GRANT OPTION;
GRANT SELECT(a) ON TABLE db3.t2 TO grantee WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON TABLE db3.t1 TO grantee WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON FUNCTION db3.f1 TO grantee WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON PROCEDURE db3.p1 TO grantee WITH GRANT OPTION;

-- connect (con1, localhost, grantee,grantee1,)
-- connection con1
SELECT user(), current_user();
SHOW GRANTS;
USE db2;
CREATE TABLE t1(f1 int);
USE db3;
SELECT a FROM t2;
INSERT INTO t1 (b) VALUES (1), (2);
SELECT f1();
CALL p1();
-- disconnect con1

-- connection default
DROP DATABASE db2;
DROP DATABASE db3;
DROP USER grantee@localhost;
DROP USER grantee;
8 changes: 5 additions & 3 deletions sql/sql_acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6940,7 +6940,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
*/

if (!strcmp(lex_user->user.str,user) &&
!my_strcasecmp(system_charset_info, lex_user->host.str, host))
acl_db->host.compare_hostname(lex_user->host.str, lex_user->host.str))
{
want_access=acl_db->access;
if (want_access)
Expand Down Expand Up @@ -7010,7 +7010,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
*/

if (!strcmp(lex_user->user.str,user) &&
!my_strcasecmp(system_charset_info, lex_user->host.str, host))
grant_table->host.compare_hostname(lex_user->host.str,
lex_user->host.str))
{
ulong table_access= grant_table->privs;
if ((table_access | grant_table->cols) != 0)
Expand Down Expand Up @@ -7159,7 +7160,8 @@ static int show_routine_grants(THD* thd, LEX_USER *lex_user, HASH *hash,
*/

if (!strcmp(lex_user->user.str,user) &&
!my_strcasecmp(system_charset_info, lex_user->host.str, host))
grant_proc->host.compare_hostname(lex_user->host.str,
lex_user->host.str))
{
ulong proc_access= grant_proc->privs;
if (proc_access != 0)
Expand Down

0 comments on commit 42f275a

Please sign in to comment.