From f44d305a468bf8266d9673f52831b74c2b0212c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 5 Jul 2018 12:49:46 +0300 Subject: [PATCH] MXS-1949: Fix user injection warning If a service has no active servers and users are injected, a warning would be logged. This is a misleading warning if the service has no servers and should only be logged if the failure to load any users is an unexpected situation. --- .../authenticator/MySQLAuth/mysql_auth.c | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/server/modules/authenticator/MySQLAuth/mysql_auth.c b/server/modules/authenticator/MySQLAuth/mysql_auth.c index 162ab5872..cb4696a46 100644 --- a/server/modules/authenticator/MySQLAuth/mysql_auth.c +++ b/server/modules/authenticator/MySQLAuth/mysql_auth.c @@ -567,6 +567,19 @@ static bool add_service_user(SERV_LISTENER *port) return rval; } +static bool service_has_servers(SERVICE* service) +{ + for (SERVER_REF* s = service->dbref; s; s = s->next) + { + if (s->active) + { + return true; + } + } + + return false; +} + /** * @brief Load MySQL authentication users * @@ -623,9 +636,12 @@ static int mysql_auth_load_users(SERV_LISTENER *port) 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); + if (service_has_servers(service)) + { + 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 && !first_load) {