From a90068cc783dd19db28543492f84acf742ce64a2 Mon Sep 17 00:00:00 2001 From: Mattia Codato Date: Wed, 5 Aug 2020 10:01:29 +0200 Subject: [PATCH] Check satellites Icinga version before relay the execute command message --- lib/icinga/apiactions.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/icinga/apiactions.cpp b/lib/icinga/apiactions.cpp index 9f139e540..86c8616d2 100644 --- a/lib/icinga/apiactions.cpp +++ b/lib/icinga/apiactions.cpp @@ -813,6 +813,21 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object, if (local) { ClusterEvents::ExecuteCommandAPIHandler(origin, execParams); } else { + /* Check if the child endpoints have Icinga version >= 2.13 */ + Zone::Ptr localZone = Zone::GetLocalZone(); + for (const Zone::Ptr& zone : ConfigType::GetObjectsByType()) { + /* Fetch immediate child zone members */ + if (zone->GetParent() == localZone) { + std::set endpoints = zone->GetEndpoints(); + + for (const Endpoint::Ptr& childEndpoint : endpoints) { + if (childEndpoint->GetIcingaVersion() < 21300) { + return ApiActions::CreateResult(400, "Endpoint '" + childEndpoint->GetName() + "' has version < 2.13."); + } + } + } + } + Dictionary::Ptr execMessage = new Dictionary(); execMessage->Set("jsonrpc", "2.0"); execMessage->Set("method", "event::ExecuteCommand");