From 12f3149eef2af2af89d8f15a479c50e1b214260f Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 20 Dec 2018 13:59:28 +0100 Subject: [PATCH] Checkable: require zone to be set if command_endpoint is set refs #6666 --- lib/icinga/checkable.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/icinga/checkable.cpp b/lib/icinga/checkable.cpp index fe2fed9e3..cb970aa1b 100644 --- a/lib/icinga/checkable.cpp +++ b/lib/icinga/checkable.cpp @@ -57,14 +57,16 @@ void Checkable::OnAllConfigLoaded() if (endpoint) { Zone::Ptr checkableZone = static_pointer_cast(GetZone()); - if (!checkableZone) - checkableZone = Zone::GetLocalZone(); + if (checkableZone) { + Zone::Ptr cmdZone = endpoint->GetZone(); - 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 be in zone '" + checkableZone->GetName() + "' or in a direct child zone thereof.")); + "Command endpoint must not be set.")); } } }