MXS-2559: Log source of loaded users
MySQLAuth now logs the server where the users were loaded from. As only the initial loading of users causes a log message, it is still possible for the source server to change without any indication of it.
This commit is contained in:
@ -136,7 +136,7 @@ const char* mariadb_users_query
|
|||||||
// We only care about users that have a default role assigned
|
// We only care about users that have a default role assigned
|
||||||
"WHERE t.default_role = u.user %s;";
|
"WHERE t.default_role = u.user %s;";
|
||||||
|
|
||||||
static int get_users(SERV_LISTENER* listener, bool skip_local);
|
static int get_users(SERV_LISTENER* listener, bool skip_local, SERVER** srv);
|
||||||
static MYSQL* gw_mysql_init(void);
|
static MYSQL* gw_mysql_init(void);
|
||||||
static int gw_mysql_set_timeouts(MYSQL* handle);
|
static int gw_mysql_set_timeouts(MYSQL* handle);
|
||||||
static char* mysql_format_user_entry(void* data);
|
static char* mysql_format_user_entry(void* data);
|
||||||
@ -192,9 +192,9 @@ static char* get_users_query(const char* server_version, int version, bool inclu
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int replace_mysql_users(SERV_LISTENER* listener, bool skip_local)
|
int replace_mysql_users(SERV_LISTENER* listener, bool skip_local, SERVER** srv)
|
||||||
{
|
{
|
||||||
int i = get_users(listener, skip_local);
|
int i = get_users(listener, skip_local, srv);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1092,7 +1092,7 @@ int get_users_from_server(MYSQL* con, SERVER_REF* server_ref, SERVICE* service,
|
|||||||
* @param users The users table into which to load the users
|
* @param users The users table into which to load the users
|
||||||
* @return -1 on any error or the number of users inserted
|
* @return -1 on any error or the number of users inserted
|
||||||
*/
|
*/
|
||||||
static int get_users(SERV_LISTENER* listener, bool skip_local)
|
static int get_users(SERV_LISTENER* listener, bool skip_local, SERVER** srv)
|
||||||
{
|
{
|
||||||
const char* service_user = NULL;
|
const char* service_user = NULL;
|
||||||
const char* service_passwd = NULL;
|
const char* service_passwd = NULL;
|
||||||
@ -1148,6 +1148,7 @@ static int get_users(SERV_LISTENER* listener, bool skip_local)
|
|||||||
|
|
||||||
if (users > total_users)
|
if (users > total_users)
|
||||||
{
|
{
|
||||||
|
*srv = server->server;
|
||||||
total_users = users;
|
total_users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -787,7 +787,8 @@ static int mysql_auth_load_users(SERV_LISTENER* port)
|
|||||||
first_load = true;
|
first_load = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int loaded = replace_mysql_users(port, first_load);
|
SERVER* srv = nullptr;
|
||||||
|
int loaded = replace_mysql_users(port, first_load, &srv);
|
||||||
bool injected = false;
|
bool injected = false;
|
||||||
|
|
||||||
if (loaded <= 0)
|
if (loaded <= 0)
|
||||||
@ -834,7 +835,9 @@ static int mysql_auth_load_users(SERV_LISTENER* port)
|
|||||||
}
|
}
|
||||||
else if (loaded > 0 && first_load)
|
else if (loaded > 0 && first_load)
|
||||||
{
|
{
|
||||||
MXS_NOTICE("[%s] Loaded %d MySQL users for listener %s.", service->name, loaded, port->name);
|
mxb_assert(srv);
|
||||||
|
MXS_NOTICE("[%s] Loaded %d MySQL users for listener %s from server %s.",
|
||||||
|
service->name, loaded, port->name, srv->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
@ -198,10 +198,11 @@ bool dbusers_save(sqlite3* src, const char* filename);
|
|||||||
*
|
*
|
||||||
* @param service The current service
|
* @param service The current service
|
||||||
* @param skip_local Skip loading of users on local MaxScale services
|
* @param skip_local Skip loading of users on local MaxScale services
|
||||||
|
* @param srv Server where the users were loaded from (output)
|
||||||
*
|
*
|
||||||
* @return -1 on any error or the number of users inserted (0 means no users at all)
|
* @return -1 on any error or the number of users inserted (0 means no users at all)
|
||||||
*/
|
*/
|
||||||
int replace_mysql_users(SERV_LISTENER* listener, bool skip_local);
|
int replace_mysql_users(SERV_LISTENER* listener, bool skip_local, SERVER** srv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Verify the user has access to the database
|
* @brief Verify the user has access to the database
|
||||||
|
|||||||
Reference in New Issue
Block a user