Merge branch '2.1' into 2.2

This commit is contained in:
Markus Mäkelä
2017-10-03 14:30:06 +03:00
39 changed files with 685 additions and 417 deletions

View File

@ -542,7 +542,7 @@ static bool check_server_permissions(SERVICE *service, SERVER* server,
bool rval = true;
sprintf(query, template, query_pw);
if (mysql_query(mysql, query) != 0)
if (mxs_mysql_query(mysql, query) != 0)
{
if (mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
{
@ -572,7 +572,7 @@ static bool check_server_permissions(SERVICE *service, SERVER* server,
}
}
if (mysql_query(mysql, "SELECT user, host, db FROM mysql.db limit 1") != 0)
if (mxs_mysql_query(mysql, "SELECT user, host, db FROM mysql.db limit 1") != 0)
{
if (mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
{
@ -600,7 +600,7 @@ static bool check_server_permissions(SERVICE *service, SERVER* server,
}
}
if (mysql_query(mysql, "SELECT user, host, db FROM mysql.tables_priv limit 1") != 0)
if (mxs_mysql_query(mysql, "SELECT user, host, db FROM mysql.tables_priv limit 1") != 0)
{
if (mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
{
@ -747,7 +747,7 @@ int get_users_from_server(MYSQL *con, SERVER_REF *server_ref, SERVICE *service,
if (query)
{
if (mysql_query(con, query) == 0)
if (mxs_mysql_query(con, query) == 0)
{
MYSQL_RES *result = mysql_store_result(con);
@ -801,7 +801,7 @@ int get_users_from_server(MYSQL *con, SERVER_REF *server_ref, SERVICE *service,
}
/** Load the list of databases */
if (mysql_query(con, "SHOW DATABASES") == 0)
if (mxs_mysql_query(con, "SHOW DATABASES") == 0)
{
MYSQL_RES *result = mysql_store_result(con);
if (result)
@ -855,15 +855,18 @@ static int get_users(SERV_LISTENER *listener, bool skip_local)
SERVER_REF *server = service->dbref;
int total_users = -1;
bool no_active_servers = true;
for (server = service->dbref; !service->svc_do_shutdown && server; server = server->next)
{
if (skip_local && server_is_mxs_service(server->server))
if (!SERVER_REF_IS_ACTIVE(server) || !SERVER_IS_ACTIVE(server->server) ||
(skip_local && server_is_mxs_service(server->server)))
{
total_users = 0;
continue;
}
no_active_servers = false;
MYSQL *con = gw_mysql_init();
if (con)
{
@ -897,7 +900,12 @@ static int get_users(SERV_LISTENER *listener, bool skip_local)
MXS_FREE(dpwd);
if (server == NULL && total_users == -1)
if (no_active_servers)
{
// This service has no servers or all servers are local MaxScale services
total_users = 0;
}
else if (server == NULL && total_users == -1)
{
MXS_ERROR("Unable to get user data from backend database for service [%s]."
" Failed to connect to any of the backend databases.", service->name);

View File

@ -592,11 +592,15 @@ static int mysql_auth_load_users(SERV_LISTENER *port)
}
int loaded = replace_mysql_users(port, skip_local);
bool injected = false;
if (loaded < 0)
if (loaded <= 0)
{
MXS_ERROR("[%s] Unable to load users for listener %s listening at [%s]:%d.", service->name,
port->name, port->address ? port->address : "::", port->port);
if (loaded < 0)
{
MXS_ERROR("[%s] Unable to load users for listener %s listening at [%s]:%d.", service->name,
port->name, port->address ? port->address : "::", port->port);
}
if (instance->inject_service_user)
{
@ -606,10 +610,20 @@ static int mysql_auth_load_users(SERV_LISTENER *port)
{
MXS_ERROR("[%s] Failed to inject service user.", port->service->name);
}
else
{
injected = true;
}
}
}
if (loaded == 0 && !skip_local)
if (injected)
{
MXS_NOTICE("[%s] No users were loaded but 'inject_service_user' is enabled. "
"Enabling service credentials for authentication until "
"database users have been successfully loaded.", service->name);
}
else if (loaded == 0 && !skip_local)
{
MXS_WARNING("[%s]: failed to load any user information. Authentication"
" will probably fail as a result.", service->name);