From f5fda9ebf0294e4fedf7f4c32f39bf22d06c710b Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 14 Jan 2016 15:33:28 +0100 Subject: [PATCH] Raise a config error for "Checkable" objects in global zones fixes #10807 --- lib/icinga/host.cpp | 9 +++++++++ lib/icinga/service.cpp | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp index 148f4e8c4..5ea6696d0 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -38,6 +38,15 @@ void Host::OnAllConfigLoaded(void) { ObjectImpl::OnAllConfigLoaded(); + String zoneName = GetZoneName(); + + if (!zoneName.IsEmpty()) { + Zone::Ptr zone = Zone::GetByName(zoneName); + + if (zone && zone->IsGlobal()) + BOOST_THROW_EXCEPTION(std::invalid_argument("Host '" + GetName() + "' cannot be put into global zone '" + zone->GetName() + "'.")); + } + HostGroup::EvaluateObjectRules(this); Array::Ptr groups = GetGroups(); diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index f7864c338..05db7f316 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -63,6 +63,15 @@ void Service::OnAllConfigLoaded(void) { ObjectImpl::OnAllConfigLoaded(); + String zoneName = GetZoneName(); + + if (!zoneName.IsEmpty()) { + Zone::Ptr zone = Zone::GetByName(zoneName); + + if (zone && zone->IsGlobal()) + BOOST_THROW_EXCEPTION(std::invalid_argument("Service '" + GetName() + "' cannot be put into global zone '" + zone->GetName() + "'.")); + } + m_Host = Host::GetByName(GetHostName()); if (m_Host)