Commit 2cf8889f authored by unknown's avatar unknown

do not show user/pass for slave unless running with show-slave-auth-info

cleanup of register_slave_on_master()


mysql-test/r/rpl000002.result:
  new output of show slave hosts
sql/mysqld.cc:
  user and password are shown in show slave hosts only if show-slave-auth-info option is on
sql/slave.cc:
  cleanup of register_slave_on_master()
sql/sql_repl.cc:
  do not show user/pass for slave unless running with show-slave-auth-info
sql/sql_repl.h:
  show-slave-auth-info
parent 6b5d02ac
......@@ -2,8 +2,8 @@ n
2000
2001
2002
Server_id Host User Password Port
2 127.0.0.1 root 9307
Server_id Host Port
2 127.0.0.1 9307
id created
1 1970-01-01 06:25:45
id created
......
......@@ -222,7 +222,8 @@ static bool opt_log,opt_update_log,opt_bin_log,opt_slow_log,opt_noacl,
opt_disable_networking=0, opt_bootstrap=0,opt_skip_show_db=0,
opt_ansi_mode=0,opt_myisam_log=0,
opt_large_files=sizeof(my_off_t) > 4;
bool opt_sql_bin_update = 0, opt_log_slave_updates = 0, opt_safe_show_db=0;
bool opt_sql_bin_update = 0, opt_log_slave_updates = 0, opt_safe_show_db=0,
opt_show_slave_auth_info = 0;
FILE *bootstrap_file=0;
int segfaulted = 0; // ensure we do not enter SIGSEGV handler twice
extern MASTER_INFO glob_mi;
......@@ -277,7 +278,7 @@ volatile ulong cached_thread_count=0;
// replication parameters, if master_host is not NULL, we are a slave
my_string master_user = (char*) "test", master_password = 0, master_host=0,
master_info_file = (char*) "master.info";
my_string report_user = (char*) "test", report_password = 0, report_host=0;
my_string report_user = 0, report_password = 0, report_host=0;
const char *localhost=LOCAL_HOST;
const char *delayed_user="DELAYED";
......@@ -2485,7 +2486,8 @@ enum options {
OPT_GEMINI_FLUSH_LOG, OPT_GEMINI_RECOVER,
OPT_GEMINI_UNBUFFERED_IO, OPT_SKIP_SAFEMALLOC,
OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS, OPT_REPORT_HOST,
OPT_REPORT_USER, OPT_REPORT_PASSWORD, OPT_REPORT_PORT
OPT_REPORT_USER, OPT_REPORT_PASSWORD, OPT_REPORT_PORT,
OPT_SHOW_SLAVE_AUTH_INFO
};
static struct option long_options[] = {
......@@ -2604,6 +2606,8 @@ static struct option long_options[] = {
{"socket", required_argument, 0, (int) OPT_SOCKET},
{"server-id", required_argument, 0, (int) OPT_SERVER_ID},
{"set-variable", required_argument, 0, 'O'},
{"show-slave-auth-info", no_argument, 0,
(int) OPT_SHOW_SLAVE_AUTH_INFO},
{"skip-bdb", no_argument, 0, (int) OPT_BDB_SKIP},
{"skip-innodb", no_argument, 0, (int) OPT_INNODB_SKIP},
{"skip-gemini", no_argument, 0, (int) OPT_GEMINI_SKIP},
......@@ -3255,6 +3259,9 @@ static void get_options(int argc,char **argv)
safemalloc_mem_limit = atoi(optarg);
#endif
break;
case OPT_SHOW_SLAVE_AUTH_INFO:
opt_show_slave_auth_info = 1;
break;
case OPT_SOCKET:
mysql_unix_port= optarg;
break;
......
......@@ -580,24 +580,16 @@ int register_slave_on_master(MYSQL* mysql)
int4store(buf, server_id);
packet.append(buf, 4);
len = strlen(report_host);
packet.append((char)(uchar)len);
packet.append(report_host, len);
len = strlen(report_user);
packet.append((char)(uchar)len);
packet.append(report_user, len);
net_store_data(&packet, report_host);
if(report_user)
net_store_data(&packet, report_user);
else
packet.append((char)0);
if(report_password)
{
len = strlen(report_password);
packet.append((char)(uchar)len);
packet.append(report_password, len);
}
net_store_data(&packet, report_user);
else
{
packet.append((char)0);
}
int2store(buf, (uint16)report_port);
packet.append(buf, 2);
......
......@@ -830,8 +830,11 @@ int show_slave_hosts(THD* thd)
List<Item> field_list;
field_list.push_back(new Item_empty_string("Server_id", 20));
field_list.push_back(new Item_empty_string("Host", 20));
if(opt_show_slave_auth_info)
{
field_list.push_back(new Item_empty_string("User",20));
field_list.push_back(new Item_empty_string("Password",20));
}
field_list.push_back(new Item_empty_string("Port",20));
if(send_fields(thd, field_list, 1))
......@@ -848,8 +851,11 @@ int show_slave_hosts(THD* thd)
packet->length(0);
net_store_data(packet, si->server_id);
net_store_data(packet, si->host);
if(opt_show_slave_auth_info)
{
net_store_data(packet, si->user);
net_store_data(packet, si->password);
}
net_store_data(packet, (uint)si->port);
if(my_net_write(net, (char*)packet->ptr(), packet->length()))
{
......
......@@ -12,6 +12,7 @@ typedef struct st_slave_info
uint16 port;
} SLAVE_INFO;
extern bool opt_show_slave_auth_info;
extern HASH slave_list;
extern char* master_host;
extern my_string opt_bin_logname, master_info_file;
......
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