diff --git a/include/maxscale/service.h b/include/maxscale/service.h index 07d379686..9dbb242e5 100644 --- a/include/maxscale/service.h +++ b/include/maxscale/service.h @@ -114,8 +114,8 @@ typedef struct service char user[MAX_SERVICE_USER_LEN]; /**< The user name to use to extract information */ char password[MAX_SERVICE_PASSWORD_LEN]; /**< The authentication data requied */ SERVICE_STATS stats; /**< The service statistics */ - int enable_root; /**< Allow root user access */ - int localhost_match_wildcard_host; /**< Match localhost against wildcard */ + bool enable_root; /**< Allow root user access */ + bool localhost_match_wildcard_host; /**< Match localhost against wildcard */ MXS_CONFIG_PARAMETER* svc_config_param;/**< list of config params and values */ int svc_config_version; /**< Version number of configuration */ bool svc_do_shutdown; /**< tells the service to exit loops etc. */ diff --git a/server/core/service.cc b/server/core/service.cc index 084b4db0a..ab4a59560 100644 --- a/server/core/service.cc +++ b/server/core/service.cc @@ -1782,16 +1782,20 @@ bool Service::dump_config(const char *filename) const dprintf(file, "%s=%s\n", CN_ROUTER, m_router_name.c_str()); dprintf(file, "%s=%s\n", CN_USER, m_user.c_str()); dprintf(file, "%s=%s\n", CN_PASSWORD, m_password.c_str()); - dprintf(file, "%s=%s\n", CN_ENABLE_ROOT_USER, enable_root ? "true" : "false"); - dprintf(file, "%s=%d\n", CN_MAX_RETRY_INTERVAL, max_retry_interval); - dprintf(file, "%s=%d\n", CN_MAX_CONNECTIONS, max_connections); - dprintf(file, "%s=%ld\n", CN_CONNECTION_TIMEOUT, conn_idle_timeout); - dprintf(file, "%s=%s\n", CN_AUTH_ALL_SERVERS, users_from_all ? "true" : "false"); - dprintf(file, "%s=%s\n", CN_STRIP_DB_ESC, strip_db_esc ? "true" : "false"); - dprintf(file, "%s=%s\n", CN_LOCALHOST_MATCH_WILDCARD_HOST, - localhost_match_wildcard_host ? "true" : "false"); - dprintf(file, "%s=%s\n", CN_LOG_AUTH_WARNINGS, log_auth_warnings ? "true" : "false"); - dprintf(file, "%s=%s\n", CN_RETRY_ON_FAILURE, retry_start ? "true" : "false"); + + const MXS_MODULE_PARAM* mp = config_service_params; + + dump_param(mp, file, CN_ENABLE_ROOT_USER, enable_root); + dump_param(mp, file, CN_MAX_RETRY_INTERVAL, max_retry_interval); + dump_param(mp, file, CN_MAX_CONNECTIONS, max_connections); + dump_param(mp, file, CN_CONNECTION_TIMEOUT, conn_idle_timeout); + dump_param(mp, file, CN_AUTH_ALL_SERVERS, users_from_all); + dump_param(mp, file, CN_STRIP_DB_ESC, strip_db_esc); + dump_param(mp, file, CN_LOCALHOST_MATCH_WILDCARD_HOST, localhost_match_wildcard_host); + dump_param(mp, file, CN_LOG_AUTH_WARNINGS, log_auth_warnings); + dump_param(mp, file, CN_RETRY_ON_FAILURE, retry_start); + dump_param(mp, file, CN_VERSION_STRING, m_version_string); + dump_param(mp, file, CN_WEIGHTBY, m_weightby); if (!m_filters.empty()) { @@ -1807,16 +1811,6 @@ bool Service::dump_config(const char *filename) const dprintf(file, "\n"); } - if (!m_version_string.empty()) - { - dprintf(file, "%s=%s\n", CN_VERSION_STRING, m_version_string.c_str()); - } - - if (!m_weightby.empty()) - { - dprintf(file, "%s=%s\n", CN_WEIGHTBY, m_weightby.c_str()); - } - if (dbref) { dprintf(file, "%s=", CN_SERVERS); @@ -1852,12 +1846,16 @@ bool Service::dump_config(const char *filename) const CN_SERVERS }; + const MXS_MODULE* mod = get_module(m_router_name.c_str(), NULL); + ss_dassert(mod); + mp = mod->parameters; + // Dump router specific parameters for (auto p = svc_config_param; p; p = p->next) { if (common_params.count(p->name) == 0) { - dprintf(file, "%s=%s\n", p->name, p->value); + dump_param(mp, file, p->name, p->value); } } diff --git a/server/modules/authenticator/MySQLAuth/dbusers.cc b/server/modules/authenticator/MySQLAuth/dbusers.cc index 72fe987a7..a3519840c 100644 --- a/server/modules/authenticator/MySQLAuth/dbusers.cc +++ b/server/modules/authenticator/MySQLAuth/dbusers.cc @@ -828,7 +828,6 @@ int get_users_from_server(MYSQL *con, SERVER_REF *server_ref, SERVICE *service, MYSQL_AUTH *instance = (MYSQL_AUTH*)listener->auth_instance; sqlite3* handle = get_handle(instance); - bool anon_user = false; int users = 0; if (query) @@ -856,13 +855,6 @@ int get_users_from_server(MYSQL *con, SERVER_REF *server_ref, SERVICE *service, add_mysql_user(handle, row[0], row[1], row[2], row[3] && strcmp(row[3], "Y") == 0, row[4]); users++; - - if (row[0] && *row[0] == '\0') - { - /** Empty username is used for the anonymous user. This means - that localhost does not match wildcard host. */ - anon_user = true; - } } mysql_free_result(result); @@ -876,12 +868,6 @@ int get_users_from_server(MYSQL *con, SERVER_REF *server_ref, SERVICE *service, MXS_FREE(query); } - /** Set the parameter if it is not configured by the user */ - if (service->localhost_match_wildcard_host == SERVICE_PARAM_UNINIT) - { - service->localhost_match_wildcard_host = anon_user ? 0 : 1; - } - /** Load the list of databases */ if (mxs_mysql_query(con, "SHOW DATABASES") == 0) {