From eda547c86f8704e33925cbfc77b0bbeda6b93137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 23 May 2019 15:38:10 +0300 Subject: [PATCH] MXS-1851: Add hard-coded protocol module check This way a hard to track crash is avoided and the user knows how to fix it. --- server/core/config.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/core/config.cc b/server/core/config.cc index df3dffced..473f38441 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -3066,6 +3066,15 @@ const char* param_type_to_str(const MXS_MODULE_PARAM* params, const char* name) return ""; } +static bool wrong_protocol_type(const std::string& type, const std::string& protocol) +{ + bool have_server_proto = strcasecmp(protocol.c_str(), "mariadbbackend") == 0 + || strcasecmp(protocol.c_str(), "mysqlbackend") == 0; + bool have_server_type = type == CN_SERVER; + + return have_server_proto != have_server_type; +} + /** * @brief Check that the configuration objects have valid parameters * @@ -3111,6 +3120,14 @@ static bool check_config_objects(CONFIG_CONTEXT* context) continue; } + // TODO: Separate the listener and server protocol objects, hard-coded checks are not good + if (wrong_protocol_type(type, config_get_string(obj->parameters, CN_PROTOCOL))) + { + MXS_ERROR("Wrong protocol module type for '%s'", obj->object); + rval = false; + continue; + } + mxb_assert(param_set); std::vector to_be_removed;