diff --git a/server/core/config.cc b/server/core/config.cc index 8c3078929..d3d395a08 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -1291,6 +1291,34 @@ const MXS_MODULE* get_module(CONFIG_CONTEXT* obj, const char* param_name, const return module ? get_module(module, module_type) : NULL; } +const char* get_missing_module_parameter_name(const CONFIG_CONTEXT* obj) +{ + std::string type = config_get_string(obj->parameters, CN_TYPE); + + if (type == CN_SERVICE && !config_get_param(obj->parameters, CN_ROUTER)) + { + return CN_ROUTER; + } + else if (type == CN_LISTENER && !config_get_param(obj->parameters, CN_PROTOCOL)) + { + return CN_PROTOCOL; + } + else if (type == CN_SERVER && !config_get_param(obj->parameters, CN_PROTOCOL)) + { + return CN_PROTOCOL; + } + else if (type == CN_MONITOR && !config_get_param(obj->parameters, CN_MODULE)) + { + return CN_MODULE; + } + else if (type == CN_FILTER && !config_get_param(obj->parameters, CN_MODULE)) + { + return CN_MODULE; + } + + return nullptr; +} + std::pair get_module_details(const CONFIG_CONTEXT* obj) { std::string type = config_get_string(obj->parameters, CN_TYPE); @@ -3044,6 +3072,15 @@ static bool check_config_objects(CONFIG_CONTEXT* context) continue; } + const char* no_module_defined = get_missing_module_parameter_name(obj); + + if (no_module_defined) + { + MXS_ERROR("'%s' is missing the required parameter '%s'", obj->object, no_module_defined); + rval = false; + continue; + } + const MXS_MODULE_PARAM* param_set = nullptr; const MXS_MODULE* mod = nullptr; std::tie(param_set, mod) = get_module_details(obj);