1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
#
# Test password expiration
#
--source include/not_embedded.inc
--echo #
--echo # Only privileged users should be able to expire passwords
--echo #
create user user1@localhost;
alter user user1@localhost password expire;
create user user2@localhost;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect(con2,localhost,user2);
connection con2;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
alter user user1@localhost password expire;
disconnect con2;
connection default;
drop user user1@localhost;
drop user user2@localhost;
--echo #
--echo # disconnect_on_expired_password=ON should deny a clients's connection
--echo # when the password is expired or put the client in sandbox mode if OFF
--echo #
create user user1@localhost password expire;
set global disconnect_on_expired_password=ON;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
--error ER_MUST_CHANGE_PASSWORD_LOGIN
connect(con1,localhost,user1);
# should allow the client to enter sandbox mode
set global disconnect_on_expired_password=OFF;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect(con1,localhost,user1);
connection con1;
--error ER_MUST_CHANGE_PASSWORD
select 1;
disconnect con1;
connection default;
drop user user1@localhost;
--echo #
--echo # connect-expired-password option passed to client should override
--echo # the behavior of disconnect_on_expired_password server system var.
--echo #
create user user1@localhost password expire;
set global disconnect_on_expired_password=ON;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
--error ER_MUST_CHANGE_PASSWORD_LOGIN
connect(con1,localhost,user1);
--exec $MYSQL --connect-expired-password -u user1 -e "set password=password('');"
drop user user1@localhost;
--echo #
--echo # Manually expiring a password should have immediate effect
--echo #
create user user1@localhost;
alter user user1@localhost password expire;
set global disconnect_on_expired_password=ON;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
--error ER_MUST_CHANGE_PASSWORD_LOGIN
connect(con1,localhost,user1);
drop user user1@localhost;
--echo #
--echo # Sandbox mode should only allow change password statements
--echo #
create user user1@localhost password expire;
grant create user on *.* to user1@localhost;
set global disconnect_on_expired_password=OFF;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect(con1,localhost,user1);
connection con1;
--error ER_MUST_CHANGE_PASSWORD
select 1;
set password=password('');
select 1;
disconnect con1;
connection default;
drop user user1@localhost;
--echo #
--echo # Passwords are still expired after acl reload
--echo #
set global disconnect_on_expired_password=ON;
create user user1@localhost password expire;
flush privileges;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
--error ER_MUST_CHANGE_PASSWORD_LOGIN
connect(con1,localhost,user1);
drop user user1@localhost;
--echo #
--echo # JSON functions on global_priv reflect the correct state
--echo # of the password expiration columns
--echo #
create user user1@localhost password expire;
select host, user, JSON_VALUE(Priv, '$.password_last_changed') from mysql.global_priv where user='user1';
alter user user1@localhost password expire never;
select host, user, JSON_VALUE(Priv, '$.password_lifetime') from mysql.global_priv where user='user1';
alter user user1@localhost password expire default;
select host, user, JSON_VALUE(Priv, '$.password_lifetime') from mysql.global_priv where user='user1';
alter user user1@localhost password expire interval 123 day;
select host, user, JSON_VALUE(Priv, '$.password_lifetime') from mysql.global_priv where user='user1';
drop user user1@localhost;
--echo #
--echo # SHOW CREATE USER correctly displays the locking state of an user
--echo #
create user user1@localhost;
show create user user1@localhost;
alter user user1@localhost password expire;
show create user user1@localhost;
set password for user1@localhost= password('');
alter user user1@localhost password expire default;
show create user user1@localhost;
alter user user1@localhost password expire never;
show create user user1@localhost;
alter user user1@localhost password expire interval 123 day;
show create user user1@localhost;
alter user user1@localhost password expire;
show create user user1@localhost;
set password for user1@localhost= password('');
show create user user1@localhost;
drop user user1@localhost;
--echo #
--echo # Incorrect INTERVAL values should be rejected
--echo #
--error ER_WRONG_VALUE
create user user1@localhost password expire interval 0 day;
--echo #
--echo # Password expiration fields are loaded properly on 10.3 tables
--echo #
--source include/switch_to_mysql_user.inc
create user user1@localhost;
show create user user1@localhost;
flush privileges;
show create user user1@localhost;
alter user user1@localhost password expire;
show create user user1@localhost;
flush privileges;
show create user user1@localhost;
set password for user1@localhost= password('');
alter user user1@localhost password expire default;
show create user user1@localhost;
flush privileges;
show create user user1@localhost;
alter user user1@localhost password expire never;
show create user user1@localhost;
flush privileges;
show create user user1@localhost;
alter user user1@localhost password expire interval 123 day;
show create user user1@localhost;
flush privileges;
show create user user1@localhost;
alter user user1@localhost password expire;
show create user user1@localhost;
flush privileges;
show create user user1@localhost;
set global disconnect_on_expired_password=ON;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
--error ER_MUST_CHANGE_PASSWORD_LOGIN
connect(con1,localhost,user1);
set global disconnect_on_expired_password=OFF;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect(con1,localhost,user1);
connection con1;
--error ER_MUST_CHANGE_PASSWORD
select 1;
set password=password('');
select 1;
disconnect con1;
connection default;
drop user user1@localhost;
set global disconnect_on_expired_password=default;
set global default_password_lifetime=default;
--source include/switch_to_mysql_global_priv.inc
#
# Test password expiration INTERVAL and default_password_lifetime options
#
--echo #
--echo # PASSWORD EXPIRE DEFAULT should use the default_password_lifetime
--echo # system var to set the number of days till expiration
--echo #
set global disconnect_on_expired_password= ON;
set global default_password_lifetime= 2;
create user user1@localhost password expire default;
set @tstamp_expired= UNIX_TIMESTAMP(NOW() - INTERVAL 3 DAY);
update mysql.global_priv set
priv=json_set(priv, '$.password_last_changed', @tstamp_expired)
where user='user1';
flush privileges;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
--error ER_MUST_CHANGE_PASSWORD_LOGIN
connect(con1,localhost,user1);
drop user user1@localhost;
--echo #
--echo # PASSWORD EXPIRE INTERVAL should expire a client's password after
--echo # X days and not before
--echo #
set global disconnect_on_expired_password= ON;
create user user1@localhost password expire interval 2 day;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect(con1,localhost,user1);
disconnect con1;
connection default;
set @tstamp_expired= UNIX_TIMESTAMP(NOW() - INTERVAL 3 DAY);
update mysql.global_priv set
priv=json_set(priv, '$.password_last_changed', @tstamp_expired)
where user='user1';
flush privileges;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
--error ER_MUST_CHANGE_PASSWORD_LOGIN
connect(con1,localhost,user1);
drop user user1@localhost;
--echo #
--echo # PASSWORD EXPIRE NEVER should override the other policies and never
--echo # expire a client's password
--echo #
set global disconnect_on_expired_password= ON;
create user user1@localhost password expire interval 2 day;
alter user user1@localhost password expire never;
set @tstamp_expired= UNIX_TIMESTAMP() - 3;
update mysql.global_priv set
priv=json_set(priv, '$.password_last_changed', @tstamp_expired)
where user='user1';
flush privileges;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect(con1,localhost,user1);
disconnect con1;
connection default;
drop user user1@localhost;
set global disconnect_on_expired_password= default;
set global default_password_lifetime= default;
|