]> granicus.if.org Git - icinga2/commitdiff
Make duplicate object definitions an error.
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 20 Mar 2014 14:37:59 +0000 (15:37 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 20 Mar 2014 14:38:29 +0000 (15:38 +0100)
Fixes #3638

lib/config/config_parser.yy

index 80ebe126b28cceb049d2925e3ffd5219459d7ce1..87ed3a378f2ec1e4ed51c3996e512e47ba12c744 100644 (file)
@@ -366,6 +366,17 @@ object_declaration identifier T_STRING object_inherits_specifier expressionlist
        {
                ConfigItemBuilder::Ptr item = make_shared<ConfigItemBuilder>(yylloc);
 
+               ConfigItem::Ptr oldItem = ConfigItem::GetObject($3, $4);
+
+               if (oldItem) {
+                       std::ostringstream msgbuf;
+                       msgbuf << "Object '" << $4 << "' of type '" << $3 << "' re-defined; previous definition: " << oldItem->GetDebugInfo();
+                       free($3);
+                       free($4);
+                       delete $5;
+                       BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str()));
+               }
+
                item->SetType($3);
 
                if (strchr($4, '!') != NULL) {