From: Gunnar Beutner Date: Fri, 22 Aug 2014 11:46:32 +0000 (+0200) Subject: Make sure that child zones accept commands from their parent zone X-Git-Tag: v2.1.0~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=913e35da9e70239b2be89cdab417a3a752016441;p=icinga2 Make sure that child zones accept commands from their parent zone refs #6964 --- diff --git a/lib/icinga/apievents.cpp b/lib/icinga/apievents.cpp index 4d82e97bc..bb791c3ee 100644 --- a/lib/icinga/apievents.cpp +++ b/lib/icinga/apievents.cpp @@ -982,8 +982,14 @@ Value ApiEvents::UpdateRepositoryAPIHandler(const MessageOrigin& origin, const D Host::Ptr ApiEvents::FindHostByVirtualName(const String& hostName, const MessageOrigin& origin) { - if (origin.FromZone && hostName == "localhost") - return Host::GetByName(origin.FromZone->GetName()); - else - return Host::GetByName(hostName); + if (origin.FromZone) { + Zone::Ptr my_zone = Zone::GetLocalZone(); + + if (origin.FromZone->IsChildOf(my_zone) && hostName == "localhost") + return Host::GetByName(origin.FromZone->GetName()); + else if (!origin.FromZone->IsChildOf(my_zone) && hostName == my_zone->GetName()) + return Host::GetByName("localhost"); + } + + return Host::GetByName(hostName); }