]> granicus.if.org Git - icinga2/commitdiff
Don't execute built-in commands on the master in remote command execution mode
authorMichael Friedrich <michael.friedrich@netways.de>
Mon, 1 Dec 2014 12:19:07 +0000 (13:19 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Mon, 1 Dec 2014 12:19:56 +0000 (13:19 +0100)
fixes #7708

lib/methods/clrchecktask.cpp
lib/methods/clusterchecktask.cpp
lib/methods/clusterzonechecktask.cpp
lib/methods/icingachecktask.cpp
lib/methods/nullchecktask.cpp
lib/methods/randomchecktask.cpp

index af0fd3c982bc7e2ea5089a7fd2846dbda94e0f3f..e77fd69ff4a3bd43ba2566c8827d114ad1efb03c 100644 (file)
@@ -171,7 +171,8 @@ void ClrCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
                BOOST_FOREACH(const Dictionary::Pair& kv, env) {
                        String name = kv.second;
 
-                       Value value = MacroProcessor::ResolveMacros(name, resolvers, checkable->GetLastCheckResult());
+                       Value value = MacroProcessor::ResolveMacros(name, resolvers, checkable->GetLastCheckResult(),
+                           NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
 
                        envMacros->Set(kv.first, value);
                }
@@ -187,8 +188,13 @@ void ClrCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
                if (it != l_Objects.end()) {
                        vtObject = it->second;
                } else {
-                       String clr_assembly = MacroProcessor::ResolveMacros("$clr_assembly$", resolvers, checkable->GetLastCheckResult());
-                       String clr_type = MacroProcessor::ResolveMacros("$clr_type$", resolvers, checkable->GetLastCheckResult());
+                       String clr_assembly = MacroProcessor::ResolveMacros("$clr_assembly$", resolvers, checkable->GetLastCheckResult(),
+                           NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+                       String clr_type = MacroProcessor::ResolveMacros("$clr_type$", resolvers, checkable->GetLastCheckResult(),
+                           NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+
+                       if (resolvedMacros && !useResolvedMacros)
+                               return;
 
                        vtObject = CreateClrType(clr_assembly, clr_type);
                        l_Objects[checkable] = vtObject;
index f7e665fb9eac74608c5990b1bfbca0566136c017..36f24bea44e47de2bb8e453ced881d89e6ccaeec 100644 (file)
@@ -39,6 +39,9 @@ REGISTER_SCRIPTFUNCTION(ClusterCheck, &ClusterCheckTask::ScriptFunc);
 void ClusterCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
     const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
 {
+       if (resolvedMacros && !useResolvedMacros)
+               return;
+
        ApiListener::Ptr listener = ApiListener::GetInstance();
 
        if (!listener) {
index 96ee98727116b71619ffb16b1b50eb51aa7e4b3f..a8fc94833e8ccfb656a6410d96a5eba6fab1590d 100644 (file)
@@ -56,7 +56,11 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
        resolvers.push_back(std::make_pair("command", commandObj));
        resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
 
-       String zoneName = MacroProcessor::ResolveMacros("$cluster_zone$", resolvers, checkable->GetLastCheckResult());
+       String zoneName = MacroProcessor::ResolveMacros("$cluster_zone$", resolvers, checkable->GetLastCheckResult(),
+           NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+
+       if (resolvedMacros && !useResolvedMacros)
+               return;
 
        if (zoneName.IsEmpty()) {
                cr->SetOutput("Macro 'cluster_zone' must be set.");
index 400d05f1e7070f2baf3e0c7bd50c059a18641f7a..808e1581cd556ffcab67766954db54afaf969b3b 100644 (file)
@@ -35,6 +35,9 @@ REGISTER_SCRIPTFUNCTION(IcingaCheck, &IcingaCheckTask::ScriptFunc);
 void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
     const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
 {
+       if (resolvedMacros && !useResolvedMacros)
+               return;
+
        double interval = Utility::GetTime() - Application::GetStartTime();
 
        if (interval > 60)
index efb4795d39e7066818c47b48b244493f1a8f164c..09f369ddff72a4aa8d0161c62f21bc53d13a7fee 100644 (file)
@@ -34,6 +34,9 @@ REGISTER_SCRIPTFUNCTION(NullCheck, &NullCheckTask::ScriptFunc);
 void NullCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
     const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
 {
+       if (resolvedMacros && !useResolvedMacros)
+               return;
+
        String output = "Hello from ";
        output += Utility::GetFQDN();
 
index 1b8eaca3732073c48ed0f49059d2ff4df8e260a8..79a10be525a4c9cc288e4ef563a67c509a251a21 100644 (file)
@@ -34,6 +34,9 @@ REGISTER_SCRIPTFUNCTION(RandomCheck, &RandomCheckTask::ScriptFunc);
 void RandomCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
     const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
 {
+       if (resolvedMacros && !useResolvedMacros)
+               return;
+
        String output = "Hello from ";
        output += Utility::GetFQDN();