Merge lp:~vlad-lesin/percona-server/5.6-bug-1354988 into lp:percona-server/5.6

Proposed by Vlad Lesin
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: no longer in the source branch.
Merged at revision: 743
Proposed branch: lp:~vlad-lesin/percona-server/5.6-bug-1354988
Merge into: lp:percona-server/5.6
Diff against target: 275 lines (+127/-3)
6 files modified
mysql-test/r/grant.result (+13/-0)
mysql-test/r/grant_cache.result (+2/-0)
mysql-test/r/percona_bug1354988.result (+50/-0)
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result (+4/-0)
mysql-test/t/percona_bug1354988.test (+53/-0)
sql/sql_acl.cc (+5/-3)
To merge this branch: bzr merge lp:~vlad-lesin/percona-server/5.6-bug-1354988
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+246278@code.launchpad.net

Description of the change

Bug #1354988 fix.

Use compare_hostname() function instead of my_strcasecmp() in mysql_show_grants().

To post a comment you must log in.
Revision history for this message
Vlad Lesin (vlad-lesin) wrote :
Revision history for this message
Vlad Lesin (vlad-lesin) wrote :
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mysql-test/r/grant.result'
2--- mysql-test/r/grant.result 2014-12-01 07:53:48 +0000
3+++ mysql-test/r/grant.result 2015-02-09 13:07:26 +0000
4@@ -781,6 +781,7 @@
5 Grants for mysqltest1@192.%
6 GRANT USAGE ON *.* TO 'mysqltest1'@'192.%'
7 GRANT SELECT ON `mysqltest`.`t1` TO 'mysqltest1'@'192.%'
8+GRANT DELETE ON `mysqltest`.`t1` TO 'mysqltest1'@'%'
9 show grants for mysqltest1@'%';
10 Grants for mysqltest1@%
11 GRANT USAGE ON *.* TO 'mysqltest1'@'%'
12@@ -836,6 +837,7 @@
13 Grants for mysqltest_8@%
14 GRANT USAGE ON *.* TO 'mysqltest_8'@'%'
15 GRANT SELECT ON `mysqltest`.* TO 'mysqltest_8'@'%'
16+GRANT SELECT ON `mysqltest`.* TO 'mysqltest_8'@''
17 select * from information_schema.schema_privileges
18 where grantee like "'mysqltest_8'%";
19 GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
20@@ -875,6 +877,7 @@
21 show grants for mysqltest_8@'';
22 Grants for mysqltest_8@
23 GRANT USAGE ON *.* TO 'mysqltest_8'@''
24+GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'%'
25 GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@''
26 show grants for mysqltest_8;
27 Grants for mysqltest_8@%
28@@ -884,11 +887,13 @@
29 show grants for mysqltest_8@'';
30 Grants for mysqltest_8@
31 GRANT USAGE ON *.* TO 'mysqltest_8'@''
32+GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'%'
33 GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@''
34 show grants for mysqltest_8;
35 Grants for mysqltest_8@%
36 GRANT USAGE ON *.* TO 'mysqltest_8'@'%'
37 GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'%'
38+GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@''
39 select * from information_schema.column_privileges;
40 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
41 'mysqltest_8'@'%' def test t1 a UPDATE NO
42@@ -918,6 +923,7 @@
43 show grants for mysqltest_8@'';
44 Grants for mysqltest_8@
45 GRANT USAGE ON *.* TO 'mysqltest_8'@''
46+GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@'%'
47 GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@''
48 show grants for mysqltest_8;
49 Grants for mysqltest_8@%
50@@ -927,11 +933,13 @@
51 show grants for mysqltest_8@'';
52 Grants for mysqltest_8@
53 GRANT USAGE ON *.* TO 'mysqltest_8'@''
54+GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@'%'
55 GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@''
56 show grants for mysqltest_8;
57 Grants for mysqltest_8@%
58 GRANT USAGE ON *.* TO 'mysqltest_8'@'%'
59 GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@'%'
60+GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@''
61 select * from information_schema.table_privileges;
62 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
63 'mysqltest_8'@'%' def test t1 UPDATE NO
64@@ -964,12 +972,14 @@
65 show grants for mysqltest_8@'';
66 Grants for mysqltest_8@
67 GRANT USAGE ON *.* TO 'mysqltest_8'@''
68+GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'%'
69 GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@''
70 GRANT UPDATE, UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@''
71 show grants for mysqltest_8;
72 Grants for mysqltest_8@%
73 GRANT USAGE ON *.* TO 'mysqltest_8'@'%'
74 GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'%'
75+GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@''
76 select * from information_schema.user_privileges
77 where grantee like "'mysqltest_8'%";
78 GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
79@@ -982,12 +992,15 @@
80 show grants for mysqltest_8@'';
81 Grants for mysqltest_8@
82 GRANT USAGE ON *.* TO 'mysqltest_8'@''
83+GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'%'
84 GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@''
85 GRANT UPDATE, UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@''
86 show grants for mysqltest_8;
87 Grants for mysqltest_8@%
88 GRANT USAGE ON *.* TO 'mysqltest_8'@'%'
89 GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@'%'
90+GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_8'@''
91+GRANT UPDATE, UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@''
92 drop user mysqltest_8@'';
93 show grants for mysqltest_8@'';
94 ERROR 42000: There is no such grant defined for user 'mysqltest_8' on host ''
95
96=== modified file 'mysql-test/r/grant_cache.result'
97--- mysql-test/r/grant_cache.result 2014-12-01 07:53:48 +0000
98+++ mysql-test/r/grant_cache.result 2015-02-09 13:07:26 +0000
99@@ -121,6 +121,8 @@
100 show grants for current_user();
101 Grants for @localhost
102 GRANT USAGE ON *.* TO ''@'localhost'
103+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 ''@'%'
104+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 ''@'%'
105 ----- establish connection user2 (user=mysqltest_2) -----
106 select "user2";
107 user2
108
109=== added file 'mysql-test/r/percona_bug1354988.result'
110--- mysql-test/r/percona_bug1354988.result 1970-01-01 00:00:00 +0000
111+++ mysql-test/r/percona_bug1354988.result 2015-02-09 13:07:26 +0000
112@@ -0,0 +1,50 @@
113+CREATE USER grantee@localhost IDENTIFIED BY 'grantee1';
114+CREATE USER grantee IDENTIFIED BY 'grantee2';
115+CREATE DATABASE db2;
116+CREATE DATABASE db3;
117+USE db3;
118+CREATE TABLE t1 (a INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b INT(10) UNSIGNED NOT NULL DEFAULT 0);
119+CREATE TABLE t2 (a INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b INT(10) UNSIGNED NOT NULL DEFAULT 0);
120+INSERT INTO t2 (b) VALUES (1), (2);
121+CREATE FUNCTION f1() RETURNS INT
122+BEGIN
123+RETURN 1;
124+END |
125+CREATE PROCEDURE p1()
126+BEGIN
127+SELECT 1;
128+END |
129+GRANT ALL PRIVILEGES ON db2.* TO grantee WITH GRANT OPTION;
130+GRANT SELECT(a) ON TABLE db3.t2 TO grantee WITH GRANT OPTION;
131+GRANT ALL PRIVILEGES ON TABLE db3.t1 TO grantee WITH GRANT OPTION;
132+GRANT ALL PRIVILEGES ON FUNCTION db3.f1 TO grantee WITH GRANT OPTION;
133+GRANT ALL PRIVILEGES ON PROCEDURE db3.p1 TO grantee WITH GRANT OPTION;
134+SELECT user(), current_user();
135+user() current_user()
136+grantee@localhost grantee@localhost
137+SHOW GRANTS;
138+Grants for grantee@localhost
139+GRANT USAGE ON *.* TO 'grantee'@'localhost' IDENTIFIED BY PASSWORD '*9823FF338D44DAF02422CF24DD1F879FB4F6B232'
140+GRANT ALL PRIVILEGES ON `db2`.* TO 'grantee'@'%' WITH GRANT OPTION
141+GRANT SELECT (a) ON `db3`.`t2` TO 'grantee'@'%' WITH GRANT OPTION
142+GRANT ALL PRIVILEGES ON `db3`.`t1` TO 'grantee'@'%' WITH GRANT OPTION
143+GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `db3`.`p1` TO 'grantee'@'%' WITH GRANT OPTION
144+GRANT EXECUTE, ALTER ROUTINE ON FUNCTION `db3`.`f1` TO 'grantee'@'%' WITH GRANT OPTION
145+USE db2;
146+CREATE TABLE t1(f1 int);
147+USE db3;
148+SELECT a FROM t2;
149+a
150+1
151+2
152+INSERT INTO t1 (b) VALUES (1), (2);
153+SELECT f1();
154+f1()
155+1
156+CALL p1();
157+1
158+1
159+DROP DATABASE db2;
160+DROP DATABASE db3;
161+DROP USER grantee@localhost;
162+DROP USER grantee;
163
164=== modified file 'mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result'
165--- mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result 2014-12-01 07:53:48 +0000
166+++ mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result 2015-02-09 13:07:26 +0000
167@@ -209,6 +209,8 @@
168 SHOW GRANTS;
169 Grants for @localhost
170 GRANT PROCESS ON *.* TO ''@'localhost'
171+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 ''@'%'
172+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 ''@'%'
173 SHOW processlist;
174 Id User Host db Command Time State Info Rows_sent Rows_examined
175 ID HOST_NAME information_schema Query TIME init SHOW processlist TIME_MS 0
176@@ -257,6 +259,8 @@
177 SHOW GRANTS FOR ''@'localhost';
178 Grants for @localhost
179 GRANT USAGE ON *.* TO ''@'localhost'
180+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 ''@'%'
181+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 ''@'%'
182 SELECT * FROM information_schema.processlist;
183 ID USER HOST DB COMMAND TIME STATE INFO TIME_MS ROWS_SENT ROWS_EXAMINED
184 ID HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0
185
186=== added file 'mysql-test/t/percona_bug1354988.test'
187--- mysql-test/t/percona_bug1354988.test 1970-01-01 00:00:00 +0000
188+++ mysql-test/t/percona_bug1354988.test 2015-02-09 13:07:26 +0000
189@@ -0,0 +1,53 @@
190+# The bug #1354988 test.
191+
192+CREATE USER grantee@localhost IDENTIFIED BY 'grantee1';
193+CREATE USER grantee IDENTIFIED BY 'grantee2';
194+
195+CREATE DATABASE db2;
196+
197+
198+CREATE DATABASE db3;
199+USE db3;
200+
201+CREATE TABLE t1 (a INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b INT(10) UNSIGNED NOT NULL DEFAULT 0);
202+CREATE TABLE t2 (a INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b INT(10) UNSIGNED NOT NULL DEFAULT 0);
203+INSERT INTO t2 (b) VALUES (1), (2);
204+
205+-- delimiter |
206+
207+CREATE FUNCTION f1() RETURNS INT
208+BEGIN
209+ RETURN 1;
210+END |
211+
212+CREATE PROCEDURE p1()
213+BEGIN
214+ SELECT 1;
215+END |
216+
217+-- delimiter ;
218+
219+GRANT ALL PRIVILEGES ON db2.* TO grantee WITH GRANT OPTION;
220+GRANT SELECT(a) ON TABLE db3.t2 TO grantee WITH GRANT OPTION;
221+GRANT ALL PRIVILEGES ON TABLE db3.t1 TO grantee WITH GRANT OPTION;
222+GRANT ALL PRIVILEGES ON FUNCTION db3.f1 TO grantee WITH GRANT OPTION;
223+GRANT ALL PRIVILEGES ON PROCEDURE db3.p1 TO grantee WITH GRANT OPTION;
224+
225+-- connect (con1, localhost, grantee,grantee1,)
226+-- connection con1
227+SELECT user(), current_user();
228+SHOW GRANTS;
229+USE db2;
230+CREATE TABLE t1(f1 int);
231+USE db3;
232+SELECT a FROM t2;
233+INSERT INTO t1 (b) VALUES (1), (2);
234+SELECT f1();
235+CALL p1();
236+-- disconnect con1
237+
238+-- connection default
239+DROP DATABASE db2;
240+DROP DATABASE db3;
241+DROP USER grantee@localhost;
242+DROP USER grantee;
243
244=== modified file 'sql/sql_acl.cc'
245--- sql/sql_acl.cc 2014-12-01 07:53:48 +0000
246+++ sql/sql_acl.cc 2015-02-09 13:07:26 +0000
247@@ -6940,7 +6940,7 @@
248 */
249
250 if (!strcmp(lex_user->user.str,user) &&
251- !my_strcasecmp(system_charset_info, lex_user->host.str, host))
252+ acl_db->host.compare_hostname(lex_user->host.str, lex_user->host.str))
253 {
254 want_access=acl_db->access;
255 if (want_access)
256@@ -7010,7 +7010,8 @@
257 */
258
259 if (!strcmp(lex_user->user.str,user) &&
260- !my_strcasecmp(system_charset_info, lex_user->host.str, host))
261+ grant_table->host.compare_hostname(lex_user->host.str,
262+ lex_user->host.str))
263 {
264 ulong table_access= grant_table->privs;
265 if ((table_access | grant_table->cols) != 0)
266@@ -7159,7 +7160,8 @@
267 */
268
269 if (!strcmp(lex_user->user.str,user) &&
270- !my_strcasecmp(system_charset_info, lex_user->host.str, host))
271+ grant_proc->host.compare_hostname(lex_user->host.str,
272+ lex_user->host.str))
273 {
274 ulong proc_access= grant_proc->privs;
275 if (proc_access != 0)

Subscribers

People subscribed via source and target branches