]> granicus.if.org Git - icinga2/commitdiff
Fix set_if for non-numeric boolean values
authorGunnar Beutner <gunnar@beutner.name>
Wed, 10 Dec 2014 15:49:00 +0000 (16:49 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 10 Dec 2014 15:49:00 +0000 (16:49 +0100)
fixes #8049

lib/icinga/pluginutility.cpp

index 783431b9a494443b4c5d7945d4e093206f7167d9..3fe81a98f3c71bb60e0407e540a39c6c51ddd996 100644 (file)
@@ -134,15 +134,25 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
                                        if (!missingMacro.IsEmpty())
                                                continue;
 
-                                       try {
-                                               if (!Convert::ToLong(set_if_resolved))
+                                       int value;
+
+                                       if (set_if_resolved == "true")
+                                               value = 1;
+                                       else if (set_if_resolved == "false")
+                                               value = 0;
+                                       else {
+                                               try {
+                                                       value = Convert::ToLong(set_if_resolved);
+                                               } catch (const std::exception& ex) {
+                                                       /* tried to convert a string */
+                                                       Log(LogWarning, "PluginUtility")
+                                                           << "Error evaluating set_if value '" << set_if_resolved << "': " << ex.what();
                                                        continue;
-                                       } catch (const std::exception& ex) {
-                                               /* tried to convert a string */
-                                               Log(LogWarning, "PluginUtility")
-                                                   << "Error evaluating set_if value '" << set_if_resolved << "': " << ex.what();
-                                               continue;
+                                               }
                                        }
+
+                                       if (!value)
+                                               continue;
                                }
                        }
                        else