Merge pull request #6853 from Icinga/bugfix/incorrect-command_endpoint-6666

Checkable: require zone to be set if command_endpoint is set
This commit is contained in:
Michael Friedrich 2019-02-04 13:51:31 +01:00 committed by GitHub
commit 5a8729fddd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,15 +57,17 @@ void Checkable::OnAllConfigLoaded()
if (endpoint) {
Zone::Ptr checkableZone = static_pointer_cast<Zone>(GetZone());
if (!checkableZone)
checkableZone = Zone::GetLocalZone();
if (checkableZone) {
Zone::Ptr cmdZone = endpoint->GetZone();
if (checkableZone && cmdZone != checkableZone && cmdZone->GetParent() != checkableZone) {
if (cmdZone != checkableZone && cmdZone->GetParent() != checkableZone) {
BOOST_THROW_EXCEPTION(ValidationError(this, { "command_endpoint" },
"Command endpoint must be in zone '" + checkableZone->GetName() + "' or in a direct child zone thereof."));
}
} else {
BOOST_THROW_EXCEPTION(ValidationError(this, { "command_endpoint" },
"Command endpoint must not be set."));
}
}
}