mirror of https://github.com/Icinga/icinga2.git
parent
5a17722c1f
commit
5afef1015d
|
@ -702,6 +702,13 @@ void Utility::MkDirP(const String& path, int mode)
|
|||
}
|
||||
}
|
||||
|
||||
void Utility::Remove(const String& path)
|
||||
{
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
(void)fs::remove(fs::path(path.Begin(), path.End()));
|
||||
}
|
||||
|
||||
void Utility::RemoveDirRecursive(const String& path)
|
||||
{
|
||||
namespace fs = boost::filesystem;
|
||||
|
|
|
@ -111,6 +111,7 @@ public:
|
|||
|
||||
static bool PathExists(const String& path);
|
||||
|
||||
static void Remove(const String& path);
|
||||
static void RemoveDirRecursive(const String& path);
|
||||
static void CopyFile(const String& source, const String& target);
|
||||
static void RenameFile(const String& source, const String& target);
|
||||
|
|
|
@ -107,17 +107,9 @@ void CheckResultReader::ProcessCheckResultFile(const String& path) const
|
|||
}
|
||||
|
||||
/* Remove the checkresult files. */
|
||||
if (unlink(path.CStr()) < 0)
|
||||
BOOST_THROW_EXCEPTION(posix_error()
|
||||
<< boost::errinfo_api_function("unlink")
|
||||
<< boost::errinfo_errno(errno)
|
||||
<< boost::errinfo_file_name(path));
|
||||
Utility::Remove(path);
|
||||
|
||||
if (unlink(crfile.CStr()) < 0)
|
||||
BOOST_THROW_EXCEPTION(posix_error()
|
||||
<< boost::errinfo_api_function("unlink")
|
||||
<< boost::errinfo_errno(errno)
|
||||
<< boost::errinfo_file_name(crfile));
|
||||
Utility::Remove(crfile);
|
||||
|
||||
Checkable::Ptr checkable;
|
||||
|
||||
|
|
|
@ -67,12 +67,7 @@ void ExternalCommandListener::CommandPipeThread(const String& commandPath)
|
|||
if (S_ISFIFO(statbuf.st_mode) && access(commandPath.CStr(), R_OK) >= 0) {
|
||||
fifo_ok = true;
|
||||
} else {
|
||||
if (unlink(commandPath.CStr()) < 0) {
|
||||
BOOST_THROW_EXCEPTION(posix_error()
|
||||
<< boost::errinfo_api_function("unlink")
|
||||
<< boost::errinfo_errno(errno)
|
||||
<< boost::errinfo_file_name(commandPath));
|
||||
}
|
||||
Utility::Remove(commandPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1605,12 +1605,5 @@ void ApiListener::RemoveStatusFile()
|
|||
{
|
||||
String path = Configuration::CacheDir + "/api-state.json";
|
||||
|
||||
if (Utility::PathExists(path)) {
|
||||
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
|
||||
BOOST_THROW_EXCEPTION(posix_error()
|
||||
<< boost::errinfo_api_function("unlink")
|
||||
<< boost::errinfo_errno(errno)
|
||||
<< boost::errinfo_file_name(path));
|
||||
}
|
||||
}
|
||||
Utility::Remove(path);
|
||||
}
|
||||
|
|
|
@ -124,12 +124,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
|
|||
/* Disable logging for object creation, but do so ourselves later on. */
|
||||
if (!ConfigItem::CommitItems(ascope.GetContext(), upq, newItems, true) || !ConfigItem::ActivateItems(upq, newItems, true, true)) {
|
||||
if (errors) {
|
||||
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
|
||||
BOOST_THROW_EXCEPTION(posix_error()
|
||||
<< boost::errinfo_api_function("unlink")
|
||||
<< boost::errinfo_errno(errno)
|
||||
<< boost::errinfo_file_name(path));
|
||||
}
|
||||
Utility::Remove(path);
|
||||
|
||||
for (const boost::exception_ptr& ex : upq.GetExceptions()) {
|
||||
errors->Add(DiagnosticInformation(ex, false));
|
||||
|
@ -154,12 +149,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
|
|||
<< "Created and activated object '" << fullName << "' of type '" << type->GetName() << "'.";
|
||||
|
||||
} catch (const std::exception& ex) {
|
||||
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
|
||||
BOOST_THROW_EXCEPTION(posix_error()
|
||||
<< boost::errinfo_api_function("unlink")
|
||||
<< boost::errinfo_errno(errno)
|
||||
<< boost::errinfo_file_name(path));
|
||||
}
|
||||
Utility::Remove(path);
|
||||
|
||||
if (errors)
|
||||
errors->Add(DiagnosticInformation(ex, false));
|
||||
|
@ -226,14 +216,7 @@ bool ConfigObjectUtility::DeleteObjectHelper(const ConfigObject::Ptr& object, bo
|
|||
|
||||
String path = GetObjectConfigPath(object->GetReflectionType(), name);
|
||||
|
||||
if (Utility::PathExists(path)) {
|
||||
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
|
||||
BOOST_THROW_EXCEPTION(posix_error()
|
||||
<< boost::errinfo_api_function("unlink")
|
||||
<< boost::errinfo_errno(errno)
|
||||
<< boost::errinfo_file_name(path));
|
||||
}
|
||||
}
|
||||
Utility::Remove(path);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -352,12 +352,7 @@ Value UpdateCertificateHandler(const MessageOrigin::Ptr& origin, const Dictionar
|
|||
/* Remove ticket for successful signing request. */
|
||||
String ticketPath = ApiListener::GetCertsDir() + "/ticket";
|
||||
|
||||
if (unlink(ticketPath.CStr()) < 0 && errno != ENOENT) {
|
||||
BOOST_THROW_EXCEPTION(posix_error()
|
||||
<< boost::errinfo_api_function("unlink")
|
||||
<< boost::errinfo_errno(errno)
|
||||
<< boost::errinfo_file_name(ticketPath));
|
||||
}
|
||||
Utility::Remove(ticketPath);
|
||||
|
||||
/* Update the certificates at runtime and reconnect all endpoints. */
|
||||
Log(LogInformation, "JsonRpcConnection")
|
||||
|
|
Loading…
Reference in New Issue