Skip to content

Commit 5edcf52

Browse files
committed
Merge branch 'mysql-5.6' into mysql-5.7
2 parents 7f5a460 + 0ff896b commit 5edcf52

File tree

3 files changed

+306
-58
lines changed

3 files changed

+306
-58
lines changed

mysql-test/r/validate_password_plugin.result

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ SET @@global.validate_password_special_char_count= 1;
101101
# No dictionary file present, no dictionary check
102102
SET @@global.validate_password_policy=STRONG;
103103
ALTER USER 'base_user'@'localhost' IDENTIFIED BY 'password1A#';
104-
UNINSTALL PLUGIN validate_password;
105-
# restarting the server with dictionary file.
106-
# Restart server.
107-
INSTALL PLUGIN validate_password SONAME 'validate_password.so';
104+
SET @@global.validate_password_dictionary_file="MYSQL_ERRMSG_BASEDIR/dictionary.txt";
108105
# password policy strong
109106
# default_file : dictionary.txt
110107
SET @@global.validate_password_policy=STRONG;
@@ -168,4 +165,78 @@ DROP USER 'user2'@'localhost';
168165
DROP USER 'base_user'@'localhost';
169166
DROP USER 'user1'@'localhost';
170167
DROP USER 'user'@'localhost';
168+
SET @@global.validate_password_length=default;
169+
SET @@global.validate_password_number_count=default;
170+
SET @@global.validate_password_mixed_case_count=default;
171+
SET @@global.validate_password_special_char_count=default;
172+
SET @@global.validate_password_policy=default;
173+
SET @@global.validate_password_dictionary_file=default;
174+
SELECT @@validate_password_length,
175+
@@validate_password_number_count,
176+
@@validate_password_mixed_case_count,
177+
@@validate_password_special_char_count,
178+
@@validate_password_policy,
179+
@@validate_password_dictionary_file;
180+
@@validate_password_length @@validate_password_number_count @@validate_password_mixed_case_count @@validate_password_special_char_count @@validate_password_policy @@validate_password_dictionary_file
181+
8 1 1 1 MEDIUM NULL
182+
#
183+
# Bug#14588145 - NEED ABILITY TO FLUSH PASSWORD VALIDATION DICTIONARY FILE
184+
#
185+
SET @@global.validate_password_policy=STRONG;
186+
# No dictionary file, password is accepted
187+
CREATE USER 'user1'@'localhost' IDENTIFIED BY 'passWORD123#';
188+
SET @@global.validate_password_dictionary_file="MYSQLTEST_VARDIR/tmp/dictionary2.txt";
189+
# must return 3
190+
SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS
191+
WHERE VARIABLE_NAME = 'validate_password_dictionary_file_words_count';
192+
VARIABLE_VALUE
193+
3
194+
Warnings:
195+
Warning 1287 'INFORMATION_SCHEMA.GLOBAL_STATUS' is deprecated and will be removed in a future release. Please use performance_schema.global_status instead
196+
SELECT VARIABLE_VALUE into @ts1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS
197+
WHERE VARIABLE_NAME = "validate_password_dictionary_file_last_parsed";
198+
Warnings:
199+
Warning 1287 'INFORMATION_SCHEMA.GLOBAL_STATUS' is deprecated and will be removed in a future release. Please use performance_schema.global_status instead
200+
# check format of the TS
201+
SELECT @ts1;
202+
@ts1
203+
0000-00-00 00:00:00
204+
# must return 19
205+
SELECT LENGTH(@ts1);
206+
LENGTH(@ts1)
207+
19
208+
# must sleep for at least 1 sec so that the timestamps differ
209+
SET @@global.validate_password_dictionary_file="MYSQLTEST_VARDIR/tmp/dictionary.txt";
210+
# must return 2
211+
SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS
212+
WHERE VARIABLE_NAME = 'validate_password_dictionary_file_words_count';
213+
VARIABLE_VALUE
214+
2
215+
Warnings:
216+
Warning 1287 'INFORMATION_SCHEMA.GLOBAL_STATUS' is deprecated and will be removed in a future release. Please use performance_schema.global_status instead
217+
SELECT VARIABLE_VALUE into @ts2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS
218+
WHERE VARIABLE_NAME = "validate_password_dictionary_file_last_parsed";
219+
Warnings:
220+
Warning 1287 'INFORMATION_SCHEMA.GLOBAL_STATUS' is deprecated and will be removed in a future release. Please use performance_schema.global_status instead
221+
# must return 1
222+
SELECT @ts1 <> @ts2;
223+
@ts1 <> @ts2
224+
1
225+
CREATE USER 'user2'@'localhost' IDENTIFIED BY 'passWORD123#';
226+
ERROR HY000: Your password does not satisfy the current policy requirements
227+
SET @@global.validate_password_dictionary_file=NULL;
228+
# Cache flushed and no dictionary file is loaded
229+
CREATE USER 'user2'@'localhost' IDENTIFIED BY 'passWORD123#';
230+
# Select commands to show that the validate_password lock is instrumented
231+
SELECT NAME FROM performance_schema.setup_instruments WHERE NAME LIKE '%validate%';
232+
NAME
233+
wait/synch/rwlock/validate/LOCK_dict_file
234+
SELECT NAME FROM performance_schema.rwlock_instances WHERE NAME LIKE '%validate%';
235+
NAME
236+
wait/synch/rwlock/validate/LOCK_dict_file
237+
# cleanup
238+
DROP USER 'user1'@'localhost', 'user2'@'localhost';
239+
SET @@global.validate_password_policy=DEFAULT;
240+
# clean up after the test
171241
UNINSTALL PLUGIN validate_password;
242+
End of tests

mysql-test/t/validate_password_plugin.test

Lines changed: 93 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -109,34 +109,8 @@ SET @@global.validate_password_special_char_count= 1;
109109
SET @@global.validate_password_policy=STRONG;
110110
ALTER USER 'base_user'@'localhost' IDENTIFIED BY 'password1A#';
111111

112-
UNINSTALL PLUGIN validate_password;
113-
114-
--echo # restarting the server with dictionary file.
115-
116-
# Write file to make mysql-test-run.pl wait for the server to stop
117-
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
118-
119-
# Request shutdown
120-
-- send_shutdown
121-
122-
# Call script that will poll the server waiting for it to disapear
123-
-- source include/wait_until_disconnected.inc
124-
125-
--echo # Restart server.
126-
127-
--exec echo "restart:--loose-validate_password_dictionary_file=$MYSQL_ERRMSG_BASEDIR/dictionary.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
128-
129-
# Turn on reconnect
130-
--enable_reconnect
131-
132-
# Call script that will poll the server waiting for it to be back online again
133-
--source include/wait_until_connected_again.inc
134-
135-
# Turn off reconnect again
136-
--disable_reconnect
137-
138-
--replace_regex /\.dll/.so/
139-
eval INSTALL PLUGIN validate_password SONAME '$VALIDATE_PASSWORD';
112+
--replace_result $MYSQL_ERRMSG_BASEDIR MYSQL_ERRMSG_BASEDIR
113+
eval SET @@global.validate_password_dictionary_file="$MYSQL_ERRMSG_BASEDIR/dictionary.txt";
140114

141115
--echo # password policy strong
142116
--echo # default_file : dictionary.txt
@@ -189,7 +163,7 @@ SET @@global.validate_password_special_char_count= 0;
189163
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
190164
SET @@global.validate_password_mixed_case_count= 0;
191165
# user has the update/create privilege but needs to satisfy password policy
192-
# to update/create new account
166+
# to update/create new account
193167
--error ER_NOT_VALID_PASSWORD
194168
CREATE USER 'user2'@'localhost' IDENTIFIED BY 'password';
195169
CREATE USER 'user2'@'localhost' IDENTIFIED BY 'PA00wrd!#';
@@ -204,4 +178,94 @@ connection default;
204178
DROP USER 'base_user'@'localhost';
205179
DROP USER 'user1'@'localhost';
206180
DROP USER 'user'@'localhost';
181+
SET @@global.validate_password_length=default;
182+
SET @@global.validate_password_number_count=default;
183+
SET @@global.validate_password_mixed_case_count=default;
184+
SET @@global.validate_password_special_char_count=default;
185+
SET @@global.validate_password_policy=default;
186+
SET @@global.validate_password_dictionary_file=default;
187+
188+
SELECT @@validate_password_length,
189+
@@validate_password_number_count,
190+
@@validate_password_mixed_case_count,
191+
@@validate_password_special_char_count,
192+
@@validate_password_policy,
193+
@@validate_password_dictionary_file;
194+
195+
196+
--echo #
197+
--echo # Bug#14588145 - NEED ABILITY TO FLUSH PASSWORD VALIDATION DICTIONARY FILE
198+
--echo #
199+
200+
SET @@global.validate_password_policy=STRONG;
201+
202+
--write_file $MYSQLTEST_VARDIR/tmp/dictionary.txt
203+
password
204+
validate
205+
EOF
206+
207+
--write_file $MYSQLTEST_VARDIR/tmp/dictionary2.txt
208+
password
209+
validate
210+
monkey
211+
EOF
212+
213+
--echo # No dictionary file, password is accepted
214+
CREATE USER 'user1'@'localhost' IDENTIFIED BY 'passWORD123#';
215+
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
216+
eval SET @@global.validate_password_dictionary_file="$MYSQLTEST_VARDIR/tmp/dictionary2.txt";
217+
# Dictionary file loaded
218+
219+
--echo # must return 3
220+
SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS
221+
WHERE VARIABLE_NAME = 'validate_password_dictionary_file_words_count';
222+
223+
SELECT VARIABLE_VALUE into @ts1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS
224+
WHERE VARIABLE_NAME = "validate_password_dictionary_file_last_parsed";
225+
226+
--echo # check format of the TS
227+
--replace_regex /[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/0000-00-00 00:00:00/
228+
SELECT @ts1;
229+
230+
--echo # must return 19
231+
SELECT LENGTH(@ts1);
232+
233+
--echo # must sleep for at least 1 sec so that the timestamps differ
234+
--sleep 1
235+
236+
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
237+
eval SET @@global.validate_password_dictionary_file="$MYSQLTEST_VARDIR/tmp/dictionary.txt";
238+
239+
--echo # must return 2
240+
SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS
241+
WHERE VARIABLE_NAME = 'validate_password_dictionary_file_words_count';
242+
243+
SELECT VARIABLE_VALUE into @ts2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS
244+
WHERE VARIABLE_NAME = "validate_password_dictionary_file_last_parsed";
245+
246+
--echo # must return 1
247+
SELECT @ts1 <> @ts2;
248+
249+
--error ER_NOT_VALID_PASSWORD
250+
CREATE USER 'user2'@'localhost' IDENTIFIED BY 'passWORD123#';
251+
252+
SET @@global.validate_password_dictionary_file=NULL;
253+
254+
--echo # Cache flushed and no dictionary file is loaded
255+
CREATE USER 'user2'@'localhost' IDENTIFIED BY 'passWORD123#';
256+
257+
--echo # Select commands to show that the validate_password lock is instrumented
258+
SELECT NAME FROM performance_schema.setup_instruments WHERE NAME LIKE '%validate%';
259+
SELECT NAME FROM performance_schema.rwlock_instances WHERE NAME LIKE '%validate%';
260+
261+
--echo # cleanup
262+
DROP USER 'user1'@'localhost', 'user2'@'localhost';
263+
SET @@global.validate_password_policy=DEFAULT;
264+
remove_file $MYSQLTEST_VARDIR/tmp/dictionary.txt;
265+
remove_file $MYSQLTEST_VARDIR/tmp/dictionary2.txt;
266+
267+
--echo # clean up after the test
207268
UNINSTALL PLUGIN validate_password;
269+
270+
271+
--echo End of tests

0 commit comments

Comments
 (0)