2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-22 18:08:16 +00:00

[#3831] Checkpoint: fixes

This commit is contained in:
Francis Dupont 2025-05-15 21:01:23 +02:00
parent 01dc6e538c
commit e8d9560f43
5 changed files with 16 additions and 10 deletions

View File

@ -828,6 +828,9 @@ TEST_F(CtrlAgentControllerTest, configWrite) {
// Now clean up after ourselves. // Now clean up after ourselves.
ctrl->registerCommands(); ctrl->registerCommands();
// Add a config file.
ctrl->setConfigFile(string(TEST_DATA_BUILDDIR) + string("/config.json"));
// First, build the command: // First, build the command:
string file = string(TEST_DATA_BUILDDIR) + string("/config-write.json"); string file = string(TEST_DATA_BUILDDIR) + string("/config-write.json");
string cmd_txt = "{ \"command\": \"config-write\" }"; string cmd_txt = "{ \"command\": \"config-write\" }";

View File

@ -298,9 +298,10 @@ ControlledDhcpv4Srv::commandConfigWriteHandler(const string&,
try { try {
checkWriteConfigFile(filename); checkWriteConfigFile(filename);
} catch (const isc::Exception& ex) { } catch (const isc::Exception& ex) {
return (createAnswer(CONTROL_RESULT_ERROR, std::ostringstream msg;
string("not allowed to write config into ") + msg << "not allowed to write config into " << filename
filename)); << ": " << ex.what();
return (createAnswer(CONTROL_RESULT_ERROR, msg.str()));
} }
} }

View File

@ -301,9 +301,10 @@ ControlledDhcpv6Srv::commandConfigWriteHandler(const string&,
try { try {
checkWriteConfigFile(filename); checkWriteConfigFile(filename);
} catch (const isc::Exception& ex) { } catch (const isc::Exception& ex) {
return (createAnswer(CONTROL_RESULT_ERROR, std::ostringstream msg;
string("not allowed to write config into ") + msg << "not allowed to write config into " << filename
filename)); << ": " << ex.what();
return (createAnswer(CONTROL_RESULT_ERROR, msg.str()));
} }
} }

View File

@ -512,9 +512,10 @@ DControllerBase::configWriteHandler(const std::string&,
try { try {
checkWriteConfigFile(filename); checkWriteConfigFile(filename);
} catch (const isc::Exception& ex) { } catch (const isc::Exception& ex) {
return (createAnswer(CONTROL_RESULT_ERROR, std::ostringstream msg;
std::string("not allowed to write config into ") + msg << "not allowed to write config into " << filename
filename)); << ": " << ex.what();
return (createAnswer(CONTROL_RESULT_ERROR, msg.str()));
} }
} }

View File

@ -144,7 +144,7 @@ Daemon::checkWriteConfigFile(std::string& file) {
return; return;
} }
isc_throw(isc::BadValue, "file " << file << " must be in the same " 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 std::string