From: Gunnar Beutner Date: Wed, 5 Oct 2016 12:17:26 +0000 (+0200) Subject: Fix crash when deleting config files fails X-Git-Tag: v2.6.0~90 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5cd2fadf2b2089f515cae66cc7b1bcbff3dbaab5;p=icinga2 Fix crash when deleting config files fails fixes #12860 --- diff --git a/lib/remote/configobjectutility.cpp b/lib/remote/configobjectutility.cpp index f14b68096..f6ae2ccfa 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)