1--source include/have_plugin_auth.inc
2--source include/not_embedded.inc
3--source include/count_sessions.inc
4
5call mtr.add_suppression("Did not write failed .* ");
6
7SELECT user FROM mysql.user WHERE user LIKE 'frank';
8
9--error ER_CANNOT_USER
10CREATE USER 'frank'@'localhost' IDENTIFIED BY 'password';
11
12connect (frank,localhost,frank,password,mysql);
13disconnect frank;
14connection default;
15
16--error ER_CANNOT_USER
17CREATE USER 'frank'@'%' IDENTIFIED BY 'password';
18
19connect (frank,localhost,frank,password,mysql);
20disconnect frank;
21connection default;
22
23--error ER_PASSWORD_NO_MATCH
24SET PASSWORD FOR 'frank'@'localhost' = PASSWORD('');
25
26--error ER_PASSWORD_NO_MATCH
27SET PASSWORD FOR 'frank'@'%' = PASSWORD('');
28
29--error ER_NONEXISTING_GRANT
30GRANT ALL ON mysql.* TO 'frank'@'localhost';
31
32--error ER_NONEXISTING_GRANT
33GRANT ALL ON mysql.* TO 'frank'@'%';
34
35--error ER_NONEXISTING_GRANT
36GRANT USAGE ON mysql.* TO 'frank'@'localhost';
37
38--error ER_NONEXISTING_GRANT
39GRANT USAGE ON mysql.* TO 'frank'@'%';
40
41GRANT PROXY ON 'frank'@'%' TO 'root'@'localhost';
42
43--error ER_NONEXISTING_GRANT
44GRANT PROXY ON 'root'@'localhost' TO 'frank'@'localhost';
45
46--error ER_NONEXISTING_GRANT
47GRANT PROXY ON 'root'@'localhost' TO 'frank'@'%';
48
49--error ER_NONEXISTING_GRANT
50SHOW GRANTS FOR 'frank'@'localhost';
51
52--error ER_NONEXISTING_GRANT
53SHOW GRANTS FOR 'frank'@'%';
54
55--error ER_REVOKE_GRANTS
56REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'frank'@'localhost';
57
58--error ER_NONEXISTING_GRANT
59REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'frank'@'%';
60
61--error ER_CANNOT_USER
62DROP USER 'frank'@'localhost';
63
64--error ER_CANNOT_USER
65DROP USER 'frank'@'%';
66
67CREATE USER 'mysqltest_1'@'localhost';
68
69connect (frank,localhost,frank,password,mysql);
70
71SELECT user FROM mysql.user WHERE user LIKE 'frank';
72
73SELECT USER();
74
75SELECT CURRENT_USER();
76
77SHOW DATABASES;
78
79CREATE USER 'frankjr'@'localhost' IDENTIFIED BY 'password';
80
81GRANT ALL ON mysql.* TO 'frankjr'@'localhost';
82
83REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'frankjr'@'localhost';
84
85SET PASSWORD FOR 'frankjr'@'localhost' = PASSWORD('');
86
87DROP USER 'frankjr'@'localhost';
88
89# Allowed because --utility-user-privileges has CREATE
90CREATE DATABASE mysqltest;
91
92# Allowed because --utility-user-privileges has CREATE
93CREATE TABLE mysqltest.t1 (a INT, b INT);
94
95# Allowed because --utility-user-privileges has SHOW DATABASES
96SHOW TABLES IN mysqltest;
97
98# NOT allowed because --utility-user-privileges does not have INSERT
99--error ER_TABLEACCESS_DENIED_ERROR
100INSERT INTO mysqltest.t1(a, b) VALUES (1, 1);
101
102# NOT allowed because --utility-user-privileges does not have SELECT
103--error ER_TABLEACCESS_DENIED_ERROR
104SELECT * FROM mysqltest.t1;
105
106# NOT allowed because --utility-user-privileges does not have ALTER
107--error ER_TABLEACCESS_DENIED_ERROR
108ALTER TABLE mysqltest.t1 DROP COLUMN b;
109
110# Allowed because --utility-user-privileges has DROP
111DROP DATABASE mysqltest;
112
113SET PASSWORD FOR 'mysqltest_1'@'localhost' = PASSWORD('newpass');
114
115SET @testtemp= @@global.innodb_fast_shutdown;
116SET @@global.innodb_fast_shutdown= 2;
117SELECT @@global.innodb_fast_shutdown;
118SET @@global.innodb_fast_shutdown= 0;
119SELECT @@global.innodb_fast_shutdown;
120SET @@global.innodb_fast_shutdown= @testtemp;
121
122connection default;
123disconnect frank;
124
125#
126# cleanup from above tests
127#
128DROP USER 'mysqltest_1'@'localhost';
129
130#
131# Try to impersonate a proxied utility_user
132#
133CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'frank';
134
135SELECT plugin,authentication_string FROM mysql.user WHERE User='plug';
136
137--disable_query_log
138--error ER_ACCESS_DENIED_ERROR : this should fail : no grant
139connect(plug_con,localhost,plug,frank);
140--enable_query_log
141
142GRANT PROXY ON frank TO plug;
143
144--replace_column 1 xx 7 xx
145SELECT * FROM mysql.proxies_priv;
146
147REVOKE PROXY ON frank FROM plug;
148
149--disable_query_log
150--error ER_ACCESS_DENIED_ERROR : this should fail : no grant
151connect(plug_con,localhost,plug,frank);
152--enable_query_log
153
154connection default;
155
156DROP USER plug;
157
158# Ensure invisibility of the utility user
159
160# Restart to reset the global counters
161--source include/restart_mysqld.inc
162
163SHOW GLOBAL STATUS LIKE "Connections";
164SHOW GLOBAL STATUS LIKE "Threads%";
165
166connect (frank,localhost,frank,password,mysql);
167
168# Invisibility issue: this is the thread_id, will increase with each connection
169SHOW GLOBAL STATUS LIKE "Connections";
170# Invisibility issue: Threads_connected includes the utility user too
171# This is kept as is because this counter is used for logic within thread pool handling
172# E.g. fixing this would cause issues in threadpool_unix
173# Other Thread_ counters are fine.
174SHOW GLOBAL STATUS LIKE "Threads%";
175
176SHOW PROCESSLIST;
177
178SELECT * FROM performance_schema.users WHERE USER="frank";
179
180SELECT COUNT(*) from performance_schema.events_statements_current WHERE SQL_TEXT LIKE "%performance_schema.event_statements%";
181
182SELECT CURRENT_CONNECTIONS, TOTAL_CONNECTIONS FROM performance_schema.hosts WHERE HOST="localhost";
183SELECT * FROM performance_schema.accounts WHERE USER="frank";
184SELECT * FROM performance_schema.session_account_connect_attrs;
185SELECT COUNT(DISTINCT PROCESSLIST_ID) FROM performance_schema.session_connect_attrs;
186
187# PS-5952: Utility user visible in performance_schema.threads
188SELECT COUNT(*) from performance_schema.threads where type='FOREGROUND';
189
190
191# PS-5956: Root session must not be allowed to kill Utility user session
192--let conn_id=`select connection_id()`
193
194connection default;
195
196--error ER_KILL_DENIED_ERROR
197--eval KILL $conn_id
198
199disconnect frank;
200
201REVOKE PROXY ON 'frank'@'%' FROM 'root'@'localhost';
202
203--source include/wait_until_count_sessions.inc
204