Skip to content

Commit 3ab4458

Browse files
committed
MDEV-18119 upgrading from 10.3 to 10.4 can result in the password for a user to be wiped ou
1 parent eeaaf4a commit 3ab4458

File tree

3 files changed

+68
-10
lines changed

3 files changed

+68
-10
lines changed

mysql-test/main/mysql_upgrade.result

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ Grants for user3@%
316316
GRANT USAGE ON *.* TO 'user3'@'%'
317317
GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'
318318
DROP USER 'user3'@'%';
319-
End of 5.1 tests
319+
# End of 5.1 tests
320320
The --upgrade-system-tables option was used, user tables won't be touched.
321321
Phase 1/7: Checking and upgrading mysql database
322322
Processing databases
@@ -505,7 +505,7 @@ length(table_name)
505505
79
506506
79
507507
drop table extralongname_extralongname_extralongname_extralongname_ext;
508-
End of 10.0 tests
508+
# End of 10.0 tests
509509
set sql_mode=default;
510510
# Droping the previously created mysql_upgrade_info file..
511511
create table test.t1(a int) engine=MyISAM;
@@ -569,8 +569,8 @@ t1 CREATE TABLE `t1` (
569569
) ENGINE=MyISAM DEFAULT CHARSET=latin1
570570
DROP TABLE test.t1;
571571
SET GLOBAL enforce_storage_engine=NULL;
572-
End of 10.1 tests
573-
Start of 10.3 tests
572+
# End of 10.1 tests
573+
# End of 10.2 tests
574574
#
575575
# Ensure that mysql_upgrade correctly sets truncate_versioning_priv
576576
# on upgrade from 10.2
@@ -591,3 +591,36 @@ DROP USER 'user3'@'%';
591591
update mysql.db set Delete_history_priv='Y' where db like 'test%';
592592
drop table mysql.global_priv;
593593
rename table mysql.global_priv_bak to mysql.global_priv;
594+
# End of 10.3 tests
595+
drop view mysql.user_bak;
596+
create user 'user3'@'localhost' identified with mysql_native_password as password('a_password');
597+
show create user user3@localhost;
598+
CREATE USER for user3@localhost
599+
CREATE USER 'user3'@'localhost' IDENTIFIED BY PASSWORD '*5DC1D11F45824A9DD613961F05C1EC1E7A1601AA'
600+
update mysql.user set password=authentication_string, authentication_string='' where user='user3';
601+
select password,plugin,authentication_string from mysql.user where user='user3';
602+
password plugin authentication_string
603+
*5DC1D11F45824A9DD613961F05C1EC1E7A1601AA mysql_native_password
604+
flush privileges;
605+
show create user user3@localhost;
606+
CREATE USER for user3@localhost
607+
CREATE USER 'user3'@'localhost' IDENTIFIED BY PASSWORD '*5DC1D11F45824A9DD613961F05C1EC1E7A1601AA'
608+
connect con1,localhost,user3,a_password;
609+
select current_user();
610+
current_user()
611+
user3@localhost
612+
disconnect con1;
613+
connection default;
614+
# mysql_upgrade --force --silent 2>&1
615+
show create user user3@localhost;
616+
CREATE USER for user3@localhost
617+
CREATE USER 'user3'@'localhost' IDENTIFIED BY PASSWORD '*5DC1D11F45824A9DD613961F05C1EC1E7A1601AA'
618+
connect con1,localhost,user3,a_password;
619+
select current_user();
620+
current_user()
621+
user3@localhost
622+
disconnect con1;
623+
connection default;
624+
drop user user3@localhost;
625+
drop table mysql.global_priv;
626+
rename table mysql.global_priv_bak to mysql.global_priv;

mysql-test/main/mysql_upgrade.test

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ SHOW GRANTS FOR 'user3'@'%';
106106

107107
DROP USER 'user3'@'%';
108108

109-
--echo End of 5.1 tests
110-
109+
--echo # End of 5.1 tests
111110

112111
#
113112
# Test the --upgrade-system-tables option
@@ -192,7 +191,7 @@ create table extralongname_extralongname_extralongname_extralongname_ext (
192191
select length(table_name) from mysql.innodb_table_stats;
193192
drop table extralongname_extralongname_extralongname_extralongname_ext;
194193

195-
--echo End of 10.0 tests
194+
--echo # End of 10.0 tests
196195

197196
set sql_mode=default;
198197

@@ -218,9 +217,9 @@ DROP TABLE test.t1;
218217
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info
219218
SET GLOBAL enforce_storage_engine=NULL;
220219

221-
--echo End of 10.1 tests
220+
--echo # End of 10.1 tests
222221

223-
--echo Start of 10.3 tests
222+
--echo # End of 10.2 tests
224223

225224
--echo #
226225
--echo # Ensure that mysql_upgrade correctly sets truncate_versioning_priv
@@ -244,3 +243,29 @@ DROP USER 'user3'@'%';
244243
update mysql.db set Delete_history_priv='Y' where db like 'test%';
245244
drop table mysql.global_priv;
246245
rename table mysql.global_priv_bak to mysql.global_priv;
246+
247+
--echo # End of 10.3 tests
248+
249+
--source include/switch_to_mysql_user.inc
250+
drop view mysql.user_bak;
251+
create user 'user3'@'localhost' identified with mysql_native_password as password('a_password');
252+
show create user user3@localhost;
253+
update mysql.user set password=authentication_string, authentication_string='' where user='user3';
254+
select password,plugin,authentication_string from mysql.user where user='user3';
255+
flush privileges;
256+
show create user user3@localhost;
257+
connect con1,localhost,user3,a_password;
258+
select current_user();
259+
disconnect con1;
260+
connection default;
261+
--echo # mysql_upgrade --force --silent 2>&1
262+
--exec $MYSQL_UPGRADE --force --silent 2>&1
263+
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info
264+
show create user user3@localhost;
265+
connect con1,localhost,user3,a_password;
266+
select current_user();
267+
disconnect con1;
268+
connection default;
269+
drop user user3@localhost;
270+
drop table mysql.global_priv;
271+
rename table mysql.global_priv_bak to mysql.global_priv;

scripts/mysql_system_tables_fix.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ IF 'BASE TABLE' = (select table_type from information_schema.tables where table_
803803
'max_user_connections', max_user_connections,
804804
'max_statement_time', max_statement_time,
805805
'plugin', if(plugin>'',plugin,if(length(password)=16,'mysql_old_password','mysql_native_password')),
806-
'authentication_string', if(plugin>'',authentication_string,password),
806+
'authentication_string', if(plugin>'' and authentication_string>'',authentication_string,password),
807807
'default_role', default_role,
808808
'is_role', 'Y'=is_role)) as Priv
809809
FROM user;

0 commit comments

Comments
 (0)