]> granicus.if.org Git - icinga2/commitdiff
Fix group assignments in the config parser.
authorGunnar Beutner <gunnar@beutner.name>
Sun, 17 Nov 2013 19:50:56 +0000 (20:50 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Sun, 17 Nov 2013 19:50:56 +0000 (20:50 +0100)
Fixes #5090

lib/config/expression.cpp
lib/config/expression.h

index 6719095ba672edc3b3f8e31eec8c98232502574a..f926b7495f3d15cffd9be96b2fe9dab51c15a36e 100644 (file)
@@ -35,6 +35,37 @@ Expression::Expression(const String& key, ExpressionOperator op,
        ASSERT(op != OperatorExecute || value.IsObjectType<ExpressionList>());
 }
 
+Value Expression::DeepClone(const Value& value)
+{
+       if (value.IsObjectType<Array>()) {
+               Array::Ptr array = value;
+               Array::Ptr result = make_shared<Array>();
+
+               ObjectLock olock(array);
+
+               BOOST_FOREACH(const Value& item, array) {
+                       result->Add(DeepClone(item));
+               }
+
+               return result;
+       } else if (value.IsObjectType<Dictionary>()) {
+               Dictionary::Ptr dict = value;
+               Dictionary::Ptr result = make_shared<Dictionary>();
+
+               ObjectLock olock(dict);
+
+               String key;
+               Value item;
+               BOOST_FOREACH(boost::tuples::tie(key, item), dict) {
+                       result->Set(key, DeepClone(item));
+               }
+
+               return result;
+       }
+
+       return value;
+}
+
 void Expression::Execute(const Dictionary::Ptr& dictionary) const
 {
        Value oldValue, newValue;
@@ -75,6 +106,8 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
                                dict = make_shared<Dictionary>();
                                valueExprl->Execute(dict);
                                newValue = dict;
+                       } else {
+                               newValue = DeepClone(newValue);
                        }
 
                        break;
@@ -104,7 +137,7 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
                                String key;
                                Value value;
                                BOOST_FOREACH(boost::tie(key, value), valueDict) {
-                                       dict->Set(key, value);
+                                       dict->Set(key, DeepClone(value));
                                }
 
                                newValue = dict;
@@ -112,11 +145,10 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
                                if (!array)
                                        array = make_shared<Array>();
 
-
                                ObjectLock olock(valueArray);
 
                                BOOST_FOREACH(const Value& value, valueArray) {
-                                       array->Add(value);
+                                       array->Add(DeepClone(value));
                                }
 
                                newValue = array;
index 2313d09adb43f91295c462437683e6fffe47cc6a..85e8a2851da477eb3fec232e1428551ac11212e7 100644 (file)
@@ -73,6 +73,8 @@ private:
        ExpressionOperator m_Operator;
        Value m_Value;
        DebugInfo m_DebugInfo;
+
+       static Value DeepClone(const Value& value);
 };
 
 }