From: Gunnar Beutner Date: Mon, 9 Nov 2015 11:33:37 +0000 (+0100) Subject: Remove config file when object creation fails X-Git-Tag: v2.4.0~36 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25c490ecb64a90631fae0177829c1cfbef3a8c66;p=icinga2 Remove config file when object creation fails fixes #10578 --- diff --git a/lib/remote/configobjectutility.cpp b/lib/remote/configobjectutility.cpp index a114ef52c..91b525aa6 100644 --- a/lib/remote/configobjectutility.cpp +++ b/lib/remote/configobjectutility.cpp @@ -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));