]> granicus.if.org Git - icinga2/commitdiff
Checkable: require zone to be set if command_endpoint is set 6853/head
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Thu, 20 Dec 2018 12:59:28 +0000 (13:59 +0100)
committerAlexander A. Klimov <alexander.klimov@icinga.com>
Thu, 20 Dec 2018 12:59:28 +0000 (13:59 +0100)
refs #6666

lib/icinga/checkable.cpp

index fe2fed9e31330b32ad8ab0ff81f353bb05c040bb..cb970aa1b0a04a577cc51ddff523c4602e61fd31 100644 (file)
@@ -57,14 +57,16 @@ void Checkable::OnAllConfigLoaded()
        if (endpoint) {
                Zone::Ptr checkableZone = static_pointer_cast<Zone>(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."));
                }
        }
 }