Skip to content

Commit c2a4bfa

Browse files
committed
MDEV-18119 upgrading from 10.3 to 10.4 can result in the password for a user to be wiped out
10.1 part: SHOW CREATE USER didn't show the password, if plugin was set, but authentication_string was not
1 parent d24060b commit c2a4bfa

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

mysql-test/r/connect.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,20 @@ connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
8282
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
8383
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
8484
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
85+
select user,host,password,plugin,authentication_string from mysql.user where user='test';
86+
user host password plugin authentication_string
87+
test localhost *5FDFF3268A50F41C5D18D2CA2F754D7BDB9B3E59
88+
test 127.0.0.1 *5FDFF3268A50F41C5D18D2CA2F754D7BDB9B3E59
8589
update mysql.user set password=old_password("gambling2") where user=_binary"test";
8690
flush privileges;
91+
show grants for test@localhost;
92+
Grants for test@localhost
93+
GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' IDENTIFIED BY PASSWORD '2f27438961437573'
94+
update mysql.user set plugin='mysql_old_password' where user='test';
95+
flush privileges;
96+
show grants for test@localhost;
97+
Grants for test@localhost
98+
GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' IDENTIFIED BY PASSWORD '2f27438961437573'
8799
set password="";
88100
set password='gambling3';
89101
ERROR HY000: Password hash should be a 41-digit hexadecimal number

mysql-test/t/connect.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,13 @@ connect (fail_con,localhost,test,zorro,test2);
6666
connect (fail_con,localhost,test,zorro,);
6767

6868
# check if old password version also works
69+
select user,host,password,plugin,authentication_string from mysql.user where user='test';
6970
update mysql.user set password=old_password("gambling2") where user=_binary"test";
7071
flush privileges;
72+
show grants for test@localhost;
73+
update mysql.user set plugin='mysql_old_password' where user='test';
74+
flush privileges;
75+
show grants for test@localhost;
7176

7277
connect (con10,localhost,test,gambling2,);
7378
connect (con5,localhost,test,gambling2,mysql);

sql/sql_acl.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,8 +986,7 @@ static bool fix_user_plugin_ptr(ACL_USER *user)
986986
else
987987
return true;
988988

989-
if (user->auth_string.length)
990-
set_user_salt(user, user->auth_string.str, user->auth_string.length);
989+
set_user_salt(user, user->auth_string.str, user->auth_string.length);
991990
return false;
992991
}
993992

@@ -1457,6 +1456,11 @@ static bool acl_load(THD *thd, TABLE_LIST *tables)
14571456
safe_str(user.user.str),
14581457
safe_str(user.host.hostname));
14591458
}
1459+
else if (password_len)
1460+
{
1461+
user.auth_string.str= password;
1462+
user.auth_string.length= password_len;
1463+
}
14601464

14611465
fix_user_plugin_ptr(&user);
14621466
}

0 commit comments

Comments
 (0)