Skip to content

Commit 14ddcb1

Browse files
committed
Bug#27407480: AUTOMATIC_SP_PRIVILEGES REQUIRES NEED THE INSERT PRIVILEGES FOR MYSQL.USER TABLE
A test case and a followup fix
1 parent 43c393f commit 14ddcb1

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

mysql-test/r/sp-security.result

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,3 +617,24 @@ SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci
617617
# Connection default
618618
DROP USER user2@localhost;
619619
DROP DATABASE db1;
620+
create user foo@local_ost;
621+
create user foo@`local\_ost` identified by 'nevermore';
622+
create database foodb;
623+
grant create routine on foodb.* to foo@local_ost;
624+
select user(), current_user();
625+
user() current_user()
626+
foo@localhost foo@local_ost
627+
show grants;
628+
Grants for foo@local_ost
629+
GRANT USAGE ON *.* TO 'foo'@'local_ost'
630+
GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'local_ost'
631+
create procedure fooproc() select 'i am fooproc';
632+
show grants;
633+
Grants for foo@local_ost
634+
GRANT USAGE ON *.* TO 'foo'@'local_ost'
635+
GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'local_ost'
636+
GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `test`.`fooproc` TO 'foo'@'local_ost'
637+
drop user foo@local_ost;
638+
drop user foo@`local\_ost`;
639+
drop procedure fooproc;
640+
drop database foodb;

mysql-test/t/sp-security.test

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,24 @@ disconnect con2;
995995
DROP USER user2@localhost;
996996
DROP DATABASE db1;
997997

998+
#
999+
# Bug#27407480: AUTOMATIC_SP_PRIVILEGES REQUIRES NEED THE INSERT PRIVILEGES FOR MYSQL.USER TABLE
1000+
#
1001+
create user foo@local_ost;
1002+
create user foo@`local\_ost` identified by 'nevermore';
1003+
create database foodb;
1004+
grant create routine on foodb.* to foo@local_ost;
1005+
connect con1,localhost,foo;
1006+
select user(), current_user();
1007+
show grants;
1008+
create procedure fooproc() select 'i am fooproc';
1009+
show grants;
1010+
disconnect con1;
1011+
connection default;
1012+
drop user foo@local_ost;
1013+
drop user foo@`local\_ost`;
1014+
drop procedure fooproc;
1015+
drop database foodb;
9981016

9991017
# Wait till all disconnects are completed
10001018
--source include/wait_until_count_sessions.inc
1001-

sql/sql_acl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7190,7 +7190,7 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
71907190
mysql_mutex_lock(&acl_cache->lock);
71917191

71927192
if ((au= find_acl_user(combo->host.str= (char *) sctx->priv_host,
7193-
combo->user.str, FALSE)))
7193+
combo->user.str, TRUE)))
71947194
goto found_acl;
71957195

71967196
mysql_mutex_unlock(&acl_cache->lock);

0 commit comments

Comments
 (0)