MXS-3410 Drop anonymous users also in Xpand
As Xpand does not have a mysql.user table but a system.users table, we need to arrange things so that the query used for selecting annymous users can be different depending on the cluster.
This commit is contained in:
@ -535,8 +535,14 @@ public:
|
||||
*/
|
||||
std::string cnf_server_name;
|
||||
|
||||
private:
|
||||
protected:
|
||||
/**
|
||||
* @returns SELECT that returns anonymous users in such a way that each returned row
|
||||
* can directly be given as argument to DROP USER.
|
||||
*/
|
||||
virtual std::string anonymous_users_query() const;
|
||||
|
||||
private:
|
||||
bool check_master_node(MYSQL* conn);
|
||||
bool bad_slave_thread_status(MYSQL* conn, const char* field, int node);
|
||||
};
|
||||
|
||||
@ -59,4 +59,7 @@ public:
|
||||
|
||||
std::string block_command(int node) const override;
|
||||
std::string unblock_command(int node) const override;
|
||||
|
||||
private:
|
||||
std::string anonymous_users_query() const override;
|
||||
};
|
||||
|
||||
@ -1028,6 +1028,11 @@ std::vector<int> Mariadb_nodes::get_all_server_ids()
|
||||
return rval;
|
||||
}
|
||||
|
||||
std::string Mariadb_nodes::anonymous_users_query() const
|
||||
{
|
||||
return "SELECT CONCAT('\\'', user, '\\'@\\'', host, '\\'') FROM mysql.user WHERE user = ''";
|
||||
}
|
||||
|
||||
bool Mariadb_nodes::prepare_for_test(MYSQL* conn)
|
||||
{
|
||||
int local_result = 0;
|
||||
@ -1047,9 +1052,7 @@ bool Mariadb_nodes::prepare_for_test(MYSQL* conn)
|
||||
local_result++;
|
||||
}
|
||||
|
||||
if (mysql_query(conn,
|
||||
"SELECT CONCAT('\\'', user, '\\'@\\'', host, '\\'') FROM mysql.user WHERE user = ''")
|
||||
== 0)
|
||||
if (mysql_query(conn, anonymous_users_query().c_str()) == 0)
|
||||
{
|
||||
MYSQL_RES* res = mysql_store_result(conn);
|
||||
|
||||
|
||||
@ -275,3 +275,8 @@ std::string Xpand_nodes::unblock_command(int node) const
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
std::string Xpand_nodes::anonymous_users_query() const
|
||||
{
|
||||
return "SELECT CONCAT('\\'', user, '\\'@\\'', host, '\\'') FROM system.users WHERE user = ''";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user