From: Francis Dupont Date: Fri, 29 May 2020 17:01:39 +0000 (+0200) Subject: [#916] Made the error fatal X-Git-Tag: Kea-1.7.10~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd5b17b571eedd061ea9a01cbad29de4e78771e9;p=thirdparty%2Fkea.git [#916] Made the error fatal --- diff --git a/src/lib/process/d_controller.cc b/src/lib/process/d_controller.cc index d6343bb243..2e0c28d88c 100644 --- a/src/lib/process/d_controller.cc +++ b/src/lib/process/d_controller.cc @@ -200,11 +200,14 @@ DControllerBase::checkConfigOnly() { } if (module_config->getType() != Element::map) { isc_throw(InvalidUsage, "Config file " << config_file << - " include not map '" << getAppName() << "' entry"); + " includes not map '" << getAppName() << "' entry"); } // Handle other (i.e. not application name) objects. - handleOtherObjects(whole_config); + std::string errmsg = handleOtherObjects(whole_config); + if (!errmsg.empty()) { + isc_throw(InvalidUsage, "Config file " << config_file << errmsg); + } // Get an application process object. initProcess(); @@ -373,11 +376,14 @@ DControllerBase::configFromFile() { } if (module_config->getType() != Element::map) { isc_throw(InvalidUsage, "Config file " << config_file << - " include not map '" << getAppName() << "' entry"); + " includes not map '" << getAppName() << "' entry"); } // Handle other (i.e. not application name) objects. - handleOtherObjects(whole_config); + std::string errmsg = handleOtherObjects(whole_config); + if (!errmsg.empty()) { + isc_throw(InvalidUsage, "Config file " << config_file << errmsg); + } // Let's configure logging before applying the configuration, // so we can log things during configuration process. @@ -500,10 +506,11 @@ DControllerBase::configWriteHandler(const std::string&, + filename + " successful", params)); } -void +std::string DControllerBase::handleOtherObjects(ConstElementPtr args) { // Check obsolete or unknown (aka unsupported) objects. const std::string& app_name = getAppName(); + std::string errmsg; for (auto obj : args->mapValue()) { const std::string& obj_name = obj.first; if (obj_name == app_name) { @@ -512,7 +519,13 @@ DControllerBase::handleOtherObjects(ConstElementPtr args) { LOG_ERROR(dctl_logger, DCTL_CONFIG_DEPRECATED) .arg("'" + obj_name + "', defining anything in global level besides '" + app_name + "' is no longer supported."); + if (errmsg.empty()) { + errmsg = " contains unsupported '" + obj_name + "' parameter"; + } else { + errmsg += " (and '" + obj_name + "')"; + } } + return (errmsg); } ConstElementPtr @@ -535,6 +548,14 @@ DControllerBase::configTestHandler(const std::string&, ConstElementPtr args) { } } + if (message.empty()) { + // Handle other (i.e. not application name) objects. + std::string errmsg = handleOtherObjects(args); + if (!errmsg.empty()) { + message = "'arguments' parameter" + errmsg; + } + } + if (!message.empty()) { // Something is amiss with arguments, return a failure response. ConstElementPtr result = isc::config::createAnswer(status_code, @@ -542,8 +563,6 @@ DControllerBase::configTestHandler(const std::string&, ConstElementPtr args) { return (result); } - // Handle other (i.e. not application name) objects. - handleOtherObjects(args); // We are starting the configuration process so we should remove any // staging configuration that has been created during previous diff --git a/src/lib/process/d_controller.h b/src/lib/process/d_controller.h index 025f0a3322..4598288111 100644 --- a/src/lib/process/d_controller.h +++ b/src/lib/process/d_controller.h @@ -607,7 +607,8 @@ protected: /// - check obsolete or unknown (aka unsupported) objects. /// /// @param args Command arguments. - void handleOtherObjects(isc::data::ConstElementPtr args); + /// @return Error message or empty string. + std::string handleOtherObjects(isc::data::ConstElementPtr args); private: /// @brief Name of the service under control.