[icinga-checkins] icinga.org: icinga2/master: Fix crash when deleting config files fails

git at icinga.org git at icinga.org
Wed Oct 5 14:20:27 CEST 2016


Module: icinga2
Branch: master
Commit: 5cd2fadf2b2089f515cae66cc7b1bcbff3dbaab5
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=5cd2fadf2b2089f515cae66cc7b1bcbff3dbaab5

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed Oct  5 14:17:26 2016 +0200

Fix crash when deleting config files fails

fixes #12860

---

 lib/remote/configobjectutility.cpp |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/remote/configobjectutility.cpp b/lib/remote/configobjectutility.cpp
index f14b680..f6ae2cc 100644
--- a/lib/remote/configobjectutility.cpp
+++ b/lib/remote/configobjectutility.cpp
@@ -136,7 +136,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
 
 		if (!ConfigItem::CommitItems(ascope.GetContext(), upq, newItems) || !ConfigItem::ActivateItems(upq, newItems, true)) {
 			if (errors) {
-				if (unlink(path.CStr()) < 0) {
+				if (unlink(path.CStr()) < 0 && errno != ENOENT) {
 					BOOST_THROW_EXCEPTION(posix_error()
 					    << boost::errinfo_api_function("unlink")
 					    << boost::errinfo_errno(errno)
@@ -155,7 +155,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
 	} catch (const std::exception& ex) {
 		delete expr;
 
-		if (unlink(path.CStr()) < 0) {
+		if (unlink(path.CStr()) < 0 && errno != ENOENT) {
 			BOOST_THROW_EXCEPTION(posix_error()
 			    << boost::errinfo_api_function("unlink")
 			    << boost::errinfo_errno(errno)
@@ -217,7 +217,7 @@ bool ConfigObjectUtility::DeleteObjectHelper(const ConfigObject::Ptr& object, bo
 	String path = GetObjectConfigPath(object->GetReflectionType(), object->GetName());
 
 	if (Utility::PathExists(path)) {
-		if (unlink(path.CStr()) < 0) {
+		if (unlink(path.CStr()) < 0 && errno != ENOENT) {
 			BOOST_THROW_EXCEPTION(posix_error()
 			    << boost::errinfo_api_function("unlink")
 			    << boost::errinfo_errno(errno)



More information about the icinga-checkins mailing list