]> granicus.if.org Git - icinga2/commitdiff
Remove config file when object creation fails
authorGunnar Beutner <gunnar@beutner.name>
Mon, 9 Nov 2015 11:33:37 +0000 (12:33 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 9 Nov 2015 11:33:37 +0000 (12:33 +0100)
fixes #10578

lib/remote/configobjectutility.cpp

index a114ef52c664f8dcab0872081a9bfa541cb12058..91b525aa6b5a26308c1a5c708bf7bc0de38a2c0c 100644 (file)
@@ -113,6 +113,8 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
 
                if (!ConfigItem::CommitItems(upq) || !ConfigItem::ActivateItems(upq, false, true)) {
                        if (errors) {
+                               unlink(path.CStr());
+
                                BOOST_FOREACH(const boost::exception_ptr& ex, upq.GetExceptions()) {
                                        errors->Add(DiagnosticInformation(ex));
                                }
@@ -123,6 +125,8 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
        } catch (const std::exception& ex) {
                delete expr;
 
+               unlink(path.CStr());
+
                if (errors)
                        errors->Add(DiagnosticInformation(ex));