Skip to content

Commit f6cf7e2

Browse files
committed
upmerge of bug#12897501 from mysql-5.5
2 parents 7d10076 + 3b17a24 commit f6cf7e2

File tree

7 files changed

+113
-3
lines changed

7 files changed

+113
-3
lines changed

libmysql/client_settings.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
extern uint mysql_port;
2323
extern char * mysql_unix_port;
2424

25+
/*
26+
Note: CLIENT_CAPABILITIES is also defined in sql/client_settings.h.
27+
When adding capabilities here, consider if they should be also added to
28+
the server's version.
29+
*/
2530
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | \
2631
CLIENT_LONG_FLAG | \
2732
CLIENT_TRANSACTIONS | \

mysql-test/r/auth_rpl.result

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
include/master-slave.inc
2+
[connection master]
3+
[connection slave]
4+
include/stop_slave.inc
5+
[connection master]
6+
CREATE USER 'plug_user' IDENTIFIED WITH 'test_plugin_server' AS 'plug_user';
7+
GRANT REPLICATION SLAVE ON *.* TO plug_user;
8+
FLUSH PRIVILEGES;
9+
[connection slave]
10+
CHANGE MASTER TO MASTER_USER= 'plug_user';
11+
include/start_slave.inc
12+
# Slave in-sync with master now.
13+
SELECT user, plugin, authentication_string FROM mysql.user WHERE user LIKE 'plug_user';
14+
user plugin authentication_string
15+
plug_user test_plugin_server plug_user
16+
# Cleanup (on slave).
17+
include/stop_slave.inc
18+
CHANGE MASTER TO MASTER_USER='root';
19+
DROP USER 'plug_user';
20+
# Cleanup (on master).
21+
DROP USER 'plug_user';
22+
include/rpl_end.inc

mysql-test/t/auth_rpl-master.opt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$PLUGIN_AUTH_OPT
2+
$PLUGIN_AUTH_LOAD

mysql-test/t/auth_rpl-slave.opt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--master-retry-count=1
2+
$PLUGIN_AUTH_OPT
3+
$PLUGIN_AUTH_LOAD
4+

mysql-test/t/auth_rpl.test

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
--source include/have_plugin_auth.inc
2+
--source include/not_embedded.inc
3+
--source include/master-slave.inc
4+
5+
#
6+
# Check that replication slave can connect to master using an account
7+
# which authenticates with an external authentication plugin (bug#12897501).
8+
9+
#
10+
# First stop the slave to guarantee that nothing is replicated.
11+
#
12+
--connection slave
13+
--echo [connection slave]
14+
--source include/stop_slave.inc
15+
#
16+
# Create an replication account on the master.
17+
#
18+
--connection master
19+
--echo [connection master]
20+
CREATE USER 'plug_user' IDENTIFIED WITH 'test_plugin_server' AS 'plug_user';
21+
GRANT REPLICATION SLAVE ON *.* TO plug_user;
22+
FLUSH PRIVILEGES;
23+
24+
#
25+
# Now go to slave and change the replication user.
26+
#
27+
--connection slave
28+
--echo [connection slave]
29+
--let $master_user= query_get_value(SHOW SLAVE STATUS, Master_User, 1)
30+
CHANGE MASTER TO MASTER_USER= 'plug_user';
31+
32+
#
33+
# Start slave with new replication account - this should trigger connection
34+
# to the master server.
35+
#
36+
--source include/start_slave.inc
37+
38+
# Replicate all statements executed on master, in this case,
39+
# (creation of the plug_user account).
40+
#
41+
--connection master
42+
--sync_slave_with_master
43+
--echo # Slave in-sync with master now.
44+
45+
SELECT user, plugin, authentication_string FROM mysql.user WHERE user LIKE 'plug_user';
46+
47+
#
48+
# Now we can stop the slave and clean up.
49+
#
50+
# Note: it is important that slave is stopped at this
51+
# moment - otherwise master's cleanup statements
52+
# would be replicated on slave!
53+
#
54+
--echo # Cleanup (on slave).
55+
--source include/stop_slave.inc
56+
eval CHANGE MASTER TO MASTER_USER='$master_user';
57+
DROP USER 'plug_user';
58+
59+
--echo # Cleanup (on master).
60+
--connection master
61+
DROP USER 'plug_user';
62+
63+
--let $rpl_only_running_threads= 1
64+
--source include/rpl_end.inc

sql/client_settings.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,18 @@
2323
#include <thr_alarm.h>
2424
#include <sql_common.h>
2525

26-
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | \
27-
CLIENT_SECURE_CONNECTION | CLIENT_TRANSACTIONS | \
28-
CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION)
26+
/*
27+
Note: CLIENT_CAPABILITIES is also defined in libmysql/client_settings.h.
28+
When adding capabilities here, consider if they should be also added to
29+
the libmysql version.
30+
*/
31+
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | \
32+
CLIENT_LONG_FLAG | \
33+
CLIENT_SECURE_CONNECTION | \
34+
CLIENT_TRANSACTIONS | \
35+
CLIENT_PROTOCOL_41 | \
36+
CLIENT_SECURE_CONNECTION | \
37+
CLIENT_PLUGIN_AUTH)
2938

3039
#define read_user_name(A) {}
3140
#undef HAVE_SMEM

sql/rpl_slave.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5819,6 +5819,10 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi,
58195819
/* This one is not strictly needed but we have it here for completeness */
58205820
mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir);
58215821

5822+
/* Set MYSQL_PLUGIN_DIR in case master asks for an external authentication plugin */
5823+
if (opt_plugin_dir_ptr && *opt_plugin_dir_ptr)
5824+
mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir_ptr);
5825+
58225826
while (!(slave_was_killed = io_slave_killed(thd,mi)) &&
58235827
(reconnect ? mysql_reconnect(mysql) != 0 :
58245828
mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0,

0 commit comments

Comments
 (0)