1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-16238 root/localhost authn prioritizes authentication_string over Password

Don't let SET PASSWORD to set the password, if auth_string is set.

Now SET PASSWORD always sets the plugin/auth_string fields and clears
the password field (on pre-plugin mysql.user table it works as before).
This commit is contained in:
Sergei Golubchik
2018-06-18 21:00:25 +02:00
parent b4db59ba47
commit 5f0510225a
12 changed files with 138 additions and 104 deletions

View File

@@ -5,9 +5,9 @@
# Requirements:
#########################################
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
sync_slave_with_master;
USE test_rpl;
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
connection master;

View File

@@ -20,21 +20,21 @@ GRANT DROP ON `test`.* TO 'rpl_do_grant'@'localhost'
connection master;
set password for rpl_do_grant@localhost=password("does it work?");
connection slave;
select password<>_binary'' from mysql.user where user=_binary'rpl_do_grant';
password<>_binary''
select authentication_string<>_binary'' from mysql.user where user=_binary'rpl_do_grant';
authentication_string<>_binary''
1
connection master;
update mysql.user set password='' where user='rpl_do_grant';
update mysql.user set authentication_string='' where user='rpl_do_grant';
flush privileges;
select password<>'' from mysql.user where user='rpl_do_grant';
password<>''
select authentication_string<>'' from mysql.user where user='rpl_do_grant';
authentication_string<>''
0
set sql_mode='ANSI_QUOTES';
set password for rpl_do_grant@localhost=password('does it work?');
set sql_mode='';
connection slave;
select password<>'' from mysql.user where user='rpl_do_grant';
password<>''
select authentication_string<>'' from mysql.user where user='rpl_do_grant';
authentication_string<>''
1
connection master;
delete from mysql.user where user=_binary'rpl_do_grant';

View File

@@ -480,72 +480,72 @@ SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
******************** CREATE USER ********************
CREATE USER 'user_test_rpl'@'localhost' IDENTIFIED BY PASSWORD '*1111111111111111111111111111111111111111';
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password select_priv
localhost user_test_rpl *1111111111111111111111111111111111111111 N
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password plugin authentication_string select_priv
localhost user_test_rpl *1111111111111111111111111111111111111111 N
connection slave;
USE test_rpl;
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password select_priv
localhost user_test_rpl *1111111111111111111111111111111111111111 N
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password plugin authentication_string select_priv
localhost user_test_rpl *1111111111111111111111111111111111111111 N
connection master;
******************** GRANT ********************
GRANT SELECT ON *.* TO 'user_test_rpl'@'localhost';
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password select_priv
localhost user_test_rpl *1111111111111111111111111111111111111111 Y
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password plugin authentication_string select_priv
localhost user_test_rpl *1111111111111111111111111111111111111111 Y
connection slave;
USE test_rpl;
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password select_priv
localhost user_test_rpl *1111111111111111111111111111111111111111 Y
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password plugin authentication_string select_priv
localhost user_test_rpl *1111111111111111111111111111111111111111 Y
connection master;
******************** REVOKE ********************
REVOKE SELECT ON *.* FROM 'user_test_rpl'@'localhost';
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password select_priv
localhost user_test_rpl *1111111111111111111111111111111111111111 N
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password plugin authentication_string select_priv
localhost user_test_rpl *1111111111111111111111111111111111111111 N
connection slave;
USE test_rpl;
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password select_priv
localhost user_test_rpl *1111111111111111111111111111111111111111 N
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password plugin authentication_string select_priv
localhost user_test_rpl *1111111111111111111111111111111111111111 N
connection master;
******************** SET PASSWORD ********************
SET PASSWORD FOR 'user_test_rpl'@'localhost' = '*0000000000000000000000000000000000000000';
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password select_priv
localhost user_test_rpl *0000000000000000000000000000000000000000 N
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password plugin authentication_string select_priv
localhost user_test_rpl mysql_native_password *0000000000000000000000000000000000000000 N
connection slave;
USE test_rpl;
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password select_priv
localhost user_test_rpl *0000000000000000000000000000000000000000 N
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password plugin authentication_string select_priv
localhost user_test_rpl mysql_native_password *0000000000000000000000000000000000000000 N
connection master;
******************** RENAME USER ********************
RENAME USER 'user_test_rpl'@'localhost' TO 'user_test_rpl_2'@'localhost';
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password select_priv
localhost user_test_rpl_2 *0000000000000000000000000000000000000000 N
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password plugin authentication_string select_priv
localhost user_test_rpl_2 mysql_native_password *0000000000000000000000000000000000000000 N
connection slave;
USE test_rpl;
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password select_priv
localhost user_test_rpl_2 *0000000000000000000000000000000000000000 N
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password plugin authentication_string select_priv
localhost user_test_rpl_2 mysql_native_password *0000000000000000000000000000000000000000 N
connection master;
******************** DROP USER ********************
DROP USER 'user_test_rpl_2'@'localhost';
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password select_priv
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password plugin authentication_string select_priv
connection slave;
USE test_rpl;
SELECT host, user, password, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password select_priv
SELECT host, user, password, plugin, authentication_string, select_priv FROM mysql.user WHERE user LIKE 'user_test_rpl%';
host user password plugin authentication_string select_priv
connection master;
INSERT INTO t1 VALUES(100, 'test');

View File

@@ -27,20 +27,20 @@ show grants for rpl_do_grant@localhost;
connection master;
set password for rpl_do_grant@localhost=password("does it work?");
sync_slave_with_master;
select password<>_binary'' from mysql.user where user=_binary'rpl_do_grant';
select authentication_string<>_binary'' from mysql.user where user=_binary'rpl_do_grant';
#
# Bug#24158 SET PASSWORD in binary log fails under ANSI_QUOTES
#
connection master;
update mysql.user set password='' where user='rpl_do_grant';
update mysql.user set authentication_string='' where user='rpl_do_grant';
flush privileges;
select password<>'' from mysql.user where user='rpl_do_grant';
select authentication_string<>'' from mysql.user where user='rpl_do_grant';
set sql_mode='ANSI_QUOTES';
set password for rpl_do_grant@localhost=password('does it work?');
set sql_mode='';
sync_slave_with_master;
select password<>'' from mysql.user where user='rpl_do_grant';
select authentication_string<>'' from mysql.user where user='rpl_do_grant';
# clear what we have done, to not influence other tests.