]> granicus.if.org Git - icinga2/commitdiff
Make sure that child zones accept commands from their parent zone
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 22 Aug 2014 11:46:32 +0000 (13:46 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 22 Aug 2014 11:51:27 +0000 (13:51 +0200)
refs #6964

lib/icinga/apievents.cpp

index 4d82e97bcfadf5700f003e268882bf619e00970d..bb791c3ee8bce137ea36283b45c288424e4e0c33 100644 (file)
@@ -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);
 }