Skip to content

Commit

Permalink
MDEV-18119 upgrading from 10.3 to 10.4 can result in the password for…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
vuvova committed Jan 23, 2019
1 parent d24060b commit c2a4bfa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
12 changes: 12 additions & 0 deletions mysql-test/r/connect.result
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,20 @@ connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
select user,host,password,plugin,authentication_string from mysql.user where user='test';
user host password plugin authentication_string
test localhost *5FDFF3268A50F41C5D18D2CA2F754D7BDB9B3E59
test 127.0.0.1 *5FDFF3268A50F41C5D18D2CA2F754D7BDB9B3E59
update mysql.user set password=old_password("gambling2") where user=_binary"test";
flush privileges;
show grants for test@localhost;
Grants for test@localhost
GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' IDENTIFIED BY PASSWORD '2f27438961437573'
update mysql.user set plugin='mysql_old_password' where user='test';
flush privileges;
show grants for test@localhost;
Grants for test@localhost
GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' IDENTIFIED BY PASSWORD '2f27438961437573'
set password="";
set password='gambling3';
ERROR HY000: Password hash should be a 41-digit hexadecimal number
Expand Down
5 changes: 5 additions & 0 deletions mysql-test/t/connect.test
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ connect (fail_con,localhost,test,zorro,test2);
connect (fail_con,localhost,test,zorro,);

# check if old password version also works
select user,host,password,plugin,authentication_string from mysql.user where user='test';
update mysql.user set password=old_password("gambling2") where user=_binary"test";
flush privileges;
show grants for test@localhost;
update mysql.user set plugin='mysql_old_password' where user='test';
flush privileges;
show grants for test@localhost;

connect (con10,localhost,test,gambling2,);
connect (con5,localhost,test,gambling2,mysql);
Expand Down
8 changes: 6 additions & 2 deletions sql/sql_acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,7 @@ static bool fix_user_plugin_ptr(ACL_USER *user)
else
return true;

if (user->auth_string.length)
set_user_salt(user, user->auth_string.str, user->auth_string.length);
set_user_salt(user, user->auth_string.str, user->auth_string.length);
return false;
}

Expand Down Expand Up @@ -1457,6 +1456,11 @@ static bool acl_load(THD *thd, TABLE_LIST *tables)
safe_str(user.user.str),
safe_str(user.host.hostname));
}
else if (password_len)
{
user.auth_string.str= password;
user.auth_string.length= password_len;
}

fix_user_plugin_ptr(&user);
}
Expand Down

0 comments on commit c2a4bfa

Please sign in to comment.