Commit 8f05c848 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

MDEV-10541: Faking the version string only works with MariaDB-Clients

Our RPL_VERSION_HACK prefix caused MySQL clients to always report 5.5
major and minor versions, even if a specific fake version is passed via
my.cnf or command line parameters. When a specific version is requested,
don't employ the RPL_VERSION_HACK prefix within the server handshake
packet.
parent c22ef4df
...@@ -630,6 +630,7 @@ Time_zone *default_tz; ...@@ -630,6 +630,7 @@ Time_zone *default_tz;
const char *mysql_real_data_home_ptr= mysql_real_data_home; const char *mysql_real_data_home_ptr= mysql_real_data_home;
char server_version[SERVER_VERSION_LENGTH], *server_version_ptr; char server_version[SERVER_VERSION_LENGTH], *server_version_ptr;
bool using_custom_server_version= false;
char *mysqld_unix_port, *opt_mysql_tmpdir; char *mysqld_unix_port, *opt_mysql_tmpdir;
ulong thread_handling; ulong thread_handling;
...@@ -8960,6 +8961,7 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument) ...@@ -8960,6 +8961,7 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument)
{ {
strmake(server_version, argument, sizeof(server_version) - 1); strmake(server_version, argument, sizeof(server_version) - 1);
set_sys_var_value_origin(&server_version_ptr, sys_var::CONFIG); set_sys_var_value_origin(&server_version_ptr, sys_var::CONFIG);
using_custom_server_version= true;
} }
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
else else
......
...@@ -544,6 +544,7 @@ extern const char *mysql_real_data_home_ptr; ...@@ -544,6 +544,7 @@ extern const char *mysql_real_data_home_ptr;
extern ulong thread_handling; extern ulong thread_handling;
extern "C" MYSQL_PLUGIN_IMPORT char server_version[SERVER_VERSION_LENGTH]; extern "C" MYSQL_PLUGIN_IMPORT char server_version[SERVER_VERSION_LENGTH];
extern char *server_version_ptr; extern char *server_version_ptr;
extern bool using_custom_server_version;
extern MYSQL_PLUGIN_IMPORT char mysql_real_data_home[]; extern MYSQL_PLUGIN_IMPORT char mysql_real_data_home[];
extern char mysql_unpacked_real_data_home[]; extern char mysql_unpacked_real_data_home[];
extern MYSQL_PLUGIN_IMPORT struct system_variables global_system_variables; extern MYSQL_PLUGIN_IMPORT struct system_variables global_system_variables;
......
...@@ -12062,7 +12062,13 @@ static bool send_server_handshake_packet(MPVIO_EXT *mpvio, ...@@ -12062,7 +12062,13 @@ static bool send_server_handshake_packet(MPVIO_EXT *mpvio,
data_len= SCRAMBLE_LENGTH; data_len= SCRAMBLE_LENGTH;
} }
end= strxnmov(end, SERVER_VERSION_LENGTH, RPL_VERSION_HACK, server_version, NullS) + 1; /* When server version is specified in config file, don't include
the replication hack prefix. */
if (using_custom_server_version)
end= strnmov(end, server_version, SERVER_VERSION_LENGTH) + 1;
else
end= strxnmov(end, SERVER_VERSION_LENGTH, RPL_VERSION_HACK, server_version, NullS) + 1;
int4store((uchar*) end, mpvio->auth_info.thd->thread_id); int4store((uchar*) end, mpvio->auth_info.thd->thread_id);
end+= 4; end+= 4;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment