From: Alexander A. Klimov Date: Thu, 20 Dec 2018 12:59:28 +0000 (+0100) Subject: Checkable: require zone to be set if command_endpoint is set X-Git-Tag: v2.11.0-rc1~241^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=12f3149eef2af2af89d8f15a479c50e1b214260f;p=icinga2 Checkable: require zone to be set if command_endpoint is set refs #6666 --- 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(); - - Zone::Ptr cmdZone = endpoint->GetZone(); - - if (checkableZone && cmdZone != checkableZone && cmdZone->GetParent() != checkableZone) { + if (checkableZone) { + Zone::Ptr cmdZone = endpoint->GetZone(); + + 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.")); } } }