From e8d9560f436ec1a2e6eefbc5ad795c2080804a1e Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Thu, 15 May 2025 21:01:23 +0200 Subject: [PATCH] [#3831] Checkpoint: fixes --- src/bin/agent/tests/ca_controller_unittests.cc | 3 +++ src/bin/dhcp4/ctrl_dhcp4_srv.cc | 7 ++++--- src/bin/dhcp6/ctrl_dhcp6_srv.cc | 7 ++++--- src/lib/process/d_controller.cc | 7 ++++--- src/lib/process/daemon.cc | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/bin/agent/tests/ca_controller_unittests.cc b/src/bin/agent/tests/ca_controller_unittests.cc index 17b82b192c..df7c747087 100644 --- a/src/bin/agent/tests/ca_controller_unittests.cc +++ b/src/bin/agent/tests/ca_controller_unittests.cc @@ -828,6 +828,9 @@ TEST_F(CtrlAgentControllerTest, configWrite) { // Now clean up after ourselves. ctrl->registerCommands(); + // Add a config file. + ctrl->setConfigFile(string(TEST_DATA_BUILDDIR) + string("/config.json")); + // First, build the command: string file = string(TEST_DATA_BUILDDIR) + string("/config-write.json"); string cmd_txt = "{ \"command\": \"config-write\" }"; diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 9cf49e47cb..7bd7722abb 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -298,9 +298,10 @@ ControlledDhcpv4Srv::commandConfigWriteHandler(const string&, try { checkWriteConfigFile(filename); } catch (const isc::Exception& ex) { - return (createAnswer(CONTROL_RESULT_ERROR, - string("not allowed to write config into ") + - filename)); + std::ostringstream msg; + msg << "not allowed to write config into " << filename + << ": " << ex.what(); + return (createAnswer(CONTROL_RESULT_ERROR, msg.str())); } } diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index 304c083b8f..884ef8fa0e 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -301,9 +301,10 @@ ControlledDhcpv6Srv::commandConfigWriteHandler(const string&, try { checkWriteConfigFile(filename); } catch (const isc::Exception& ex) { - return (createAnswer(CONTROL_RESULT_ERROR, - string("not allowed to write config into ") + - filename)); + std::ostringstream msg; + msg << "not allowed to write config into " << filename + << ": " << ex.what(); + return (createAnswer(CONTROL_RESULT_ERROR, msg.str())); } } diff --git a/src/lib/process/d_controller.cc b/src/lib/process/d_controller.cc index a535ffb65b..f86b73220b 100644 --- a/src/lib/process/d_controller.cc +++ b/src/lib/process/d_controller.cc @@ -512,9 +512,10 @@ DControllerBase::configWriteHandler(const std::string&, try { checkWriteConfigFile(filename); } catch (const isc::Exception& ex) { - return (createAnswer(CONTROL_RESULT_ERROR, - std::string("not allowed to write config into ") + - filename)); + std::ostringstream msg; + msg << "not allowed to write config into " << filename + << ": " << ex.what(); + return (createAnswer(CONTROL_RESULT_ERROR, msg.str())); } } diff --git a/src/lib/process/daemon.cc b/src/lib/process/daemon.cc index fdd66128df..e5d517979f 100644 --- a/src/lib/process/daemon.cc +++ b/src/lib/process/daemon.cc @@ -144,7 +144,7 @@ Daemon::checkWriteConfigFile(std::string& file) { return; } isc_throw(isc::BadValue, "file " << file << " must be in the same " - << "directory as the config file (" << config_file_ << "'"); + << "directory as the config file (" << config_file_ << ")"); } std::string