From: Francis Dupont Date: Wed, 28 Jun 2023 14:51:57 +0000 (+0200) Subject: [#2947] Bug fixed X-Git-Tag: Kea-2.4.0~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3c87ba5f480b32f7f76acdf123ab67e3e67e62c;p=thirdparty%2Fkea.git [#2947] Bug fixed --- diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index 0de041bdf4..b62bbe116f 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -974,8 +974,9 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set, .arg(CfgMgr::instance().getStagingCfg()-> getConfigSummary(SrvConfig::CFGSEL_ALL4)); - // Also calculate SHA256 hash of the config that was just set and append it to the response. - ElementPtr config = CfgMgr::instance().getCurrentCfg()->toElement(); + // Also calculate SHA256 hash of the config that was just set and + // append it to the response. + ConstElementPtr config = CfgMgr::instance().getStagingCfg()->toElement(); string hash = BaseCommandMgr::getHash(config); ElementPtr hash_map = Element::createMap(); hash_map->set("hash", Element::create(hash)); diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc index c8fbfc79be..337371c223 100644 --- a/src/bin/dhcp6/json_config_parser.cc +++ b/src/bin/dhcp6/json_config_parser.cc @@ -1099,8 +1099,9 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set, .arg(CfgMgr::instance().getStagingCfg()-> getConfigSummary(SrvConfig::CFGSEL_ALL6)); - // Also calculate SHA256 hash of the config that was just set and append it to the response. - ElementPtr config = CfgMgr::instance().getCurrentCfg()->toElement(); + // Also calculate SHA256 hash of the config that was just set and + // append it to the response. + ConstElementPtr config = CfgMgr::instance().getStagingCfg()->toElement(); string hash = BaseCommandMgr::getHash(config); ElementPtr hash_map = Element::createMap(); hash_map->set("hash", Element::create(hash)); diff --git a/src/lib/config/base_command_mgr.cc b/src/lib/config/base_command_mgr.cc index 5a7591c735..d2d7201da6 100644 --- a/src/lib/config/base_command_mgr.cc +++ b/src/lib/config/base_command_mgr.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2023 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -191,7 +191,7 @@ BaseCommandMgr::listCommandsHandler(const std::string& /* name */, } std::string -BaseCommandMgr::getHash(isc::data::ElementPtr& config) { +BaseCommandMgr::getHash(const isc::data::ConstElementPtr& config) { // First, get the string representation. std::string config_txt = config->str(); diff --git a/src/lib/config/base_command_mgr.h b/src/lib/config/base_command_mgr.h index 28bad8dc98..916eebcc0f 100644 --- a/src/lib/config/base_command_mgr.h +++ b/src/lib/config/base_command_mgr.h @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2023 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -155,11 +155,12 @@ public: /// @brief returns a hash of a given Element structure /// - /// The hash is currently implemented as SHA256 on the string represenation of the structure. + /// The hash is currently implemented as SHA256 on the string + // representation of the structure. /// /// @param config typically full config, but hash can be calculated on any structure - /// @return string representation - static std::string getHash(isc::data::ElementPtr& config); + /// @return hash of string representation + static std::string getHash(const isc::data::ConstElementPtr& config); protected: