From 016ad77b62c75d19efe7149e0db93bea6fc60558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 27 Sep 2017 20:00:39 +0300 Subject: [PATCH] MXS-1457: Inject service credentials if no users are loaded If the authenticator option is enabled, no users are loaded and no errors have occurred in the user loading process, the service credentials are injected. --- .../authenticator/MySQLAuth/mysql_auth.c | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/server/modules/authenticator/MySQLAuth/mysql_auth.c b/server/modules/authenticator/MySQLAuth/mysql_auth.c index 1da67f120..d8e4f6e17 100644 --- a/server/modules/authenticator/MySQLAuth/mysql_auth.c +++ b/server/modules/authenticator/MySQLAuth/mysql_auth.c @@ -621,11 +621,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) { @@ -635,10 +639,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);