diff options
author | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2021-06-15 13:29:50 -0600 |
---|---|---|
committer | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2021-06-16 12:07:17 -0600 |
commit | d0809e2dd3c8e5617fb15c0b331aea35c3df3cf1 (patch) | |
tree | b054c73eae86ed274f1796269e665e059ec94616 | |
parent | 35b57c37bbbfa116da4a454df5892984550b151a (diff) | |
download | mariadb-git-bb-10.2-MDEV-23857.tar.gz |
MDEV-23857: replication master password lengthbb-10.2-MDEV-23857
Problem:
========
After MDEV-4013, the maximum length of
replication passwords was extended to 96
ASCII characters. After a restart, however,
slaves only read the first 41 characters of
MASTER_PASSWORD from the master.info file.
This lead to slaves unable to reconnect to
the master after a restart.
Solution:
========
After a slave restart, if a master.info file
is detected, use the full allowable length
of the password rather than 41 characters.
Reviewed By:
============
<TODO>
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_slave_restart_long_password.result | 28 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_slave_restart_long_password.test | 76 | ||||
-rw-r--r-- | sql/rpl_mi.cc | 2 |
3 files changed, 105 insertions, 1 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_slave_restart_long_password.result b/mysql-test/suite/rpl/r/rpl_slave_restart_long_password.result new file mode 100644 index 00000000000..52686c1b6ee --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_slave_restart_long_password.result @@ -0,0 +1,28 @@ +include/master-slave.inc +[connection master] +include/assert.inc [Password length is 96] +connection master; +SET SQL_LOG_BIN=0; +GRANT REPLICATION SLAVE ON *.* TO rpl@127.0.0.1 IDENTIFIED BY '123456789X12141618202224262830323436384042444648505254565860626466687072747678808284868890929496'; +SET SQL_LOG_BIN=1; +connection slave; +include/stop_slave.inc +CHANGE MASTER TO MASTER_HOST='127.0.0.1', master_user='rpl', master_password='123456789X12141618202224262830323436384042444648505254565860626466687072747678808284868890929496'; +include/start_slave.inc +include/check_slave_param.inc [Slave_IO_Running] +connection master; +include/rpl_restart_server.inc [server_number=2] +connection slave; +include/start_slave.inc +include/check_slave_param.inc [Slave_IO_Running] +connection master; +SET SQL_LOG_BIN=0; +DROP USER rpl@127.0.0.1; +FLUSH PRIVILEGES; +SET SQL_LOG_BIN=1; +connection slave; +include/stop_slave.inc +CHANGE MASTER TO MASTER_USER = 'root', MASTER_PASSWORD = ''; +include/start_slave.inc +connection master; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_slave_restart_long_password.test b/mysql-test/suite/rpl/t/rpl_slave_restart_long_password.test new file mode 100644 index 00000000000..f9ef1d27a01 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_slave_restart_long_password.test @@ -0,0 +1,76 @@ +# +# This test validates a fix for a bug where slaves only read the +# first 41 characters of MASTER_PASSWORD from the master.info file +# after restarts. +# +# The test ensures that passwords up to the maximum allowable +# length (96 ASCII characters) will be read from the master.info +# file after slave restarts +# +# +--source include/have_binlog_format_mixed.inc +--source include/master-slave.inc + + +##### +# Setup +# +--let $passwd=123456789X12141618202224262830323436384042444648505254565860626466687072747678808284868890929496 +--let $expected_pwlen=96 +--let assert_cond=CHAR_LENGTH("$passwd")=$expected_pwlen +--let assert_text=Password length is $expected_pwlen +--source include/assert.inc + +connection master; +SET SQL_LOG_BIN=0; +--eval GRANT REPLICATION SLAVE ON *.* TO rpl@127.0.0.1 IDENTIFIED BY '$passwd' +SET SQL_LOG_BIN=1; +##### + + +##### +# Change master to new user/password combination +# +connection slave; +--source include/stop_slave.inc +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', master_user='rpl', master_password='$passwd' + +--source include/start_slave.inc +--let $slave_param= Slave_IO_Running +--let $slave_param_value= Yes +--source include/check_slave_param.inc +##### + + +##### +# Ensure slave can re-connect to master after restart +# +connection master; +--let $rpl_server_number= 2 +--source include/rpl_restart_server.inc + +connection slave; +--source include/start_slave.inc +--let $slave_param= Slave_IO_Running +--let $slave_param_value= Yes +--source include/check_slave_param.inc +##### + + +##### +# Cleanup +# +connection master; +SET SQL_LOG_BIN=0; +DROP USER rpl@127.0.0.1; +FLUSH PRIVILEGES; +SET SQL_LOG_BIN=1; + +connection slave; +--source include/stop_slave.inc +CHANGE MASTER TO MASTER_USER = 'root', MASTER_PASSWORD = ''; +--source include/start_slave.inc + +connection master; +-- source include/rpl_end.inc +##### diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index 82a462d742b..c8773f33d44 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -480,7 +480,7 @@ file '%s')", fname); if (init_intvar_from_file(&master_log_pos, &mi->file, 4) || init_strvar_from_file(mi->host, sizeof(mi->host), &mi->file, 0) || init_strvar_from_file(mi->user, sizeof(mi->user), &mi->file, "test") || - init_strvar_from_file(mi->password, SCRAMBLED_PASSWORD_CHAR_LENGTH+1, + init_strvar_from_file(mi->password, sizeof(mi->password), &mi->file, 0) || init_intvar_from_file(&port, &mi->file, MYSQL_PORT) || init_intvar_from_file(&connect_retry, &mi->file, |