From 4e35c39df0c583254648c9ab2cc2fe4439a4af50 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 17 May 2014 12:52:31 +0200 Subject: [PATCH] Fix crash when zones.d directory doesn't exist. Fixes #6224 --- icinga-app/icinga.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 6d8d2e0d9..666ae0c0c 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -91,14 +91,15 @@ static bool LoadConfigFiles(const String& appType) } } - String zonesDir = Application::GetZonesDir(); - - if (!zonesDir.IsEmpty()) - Utility::Glob(Application::GetZonesDir() + "/*", &IncludeZoneDirRecursive, GlobDirectory); - Utility::Glob(Application::GetLocalStateDir() + "/lib/icinga2/api/zones/*", &IncludeNonLocalZone, GlobDirectory); - /* Load cluster config files - this should probably be in libremote but - * unfortunately moving it there is somewhat non-trivial. */ + * unfortunately moving it there is somewhat non-trivial. */ + String zonesEtcDir = Application::GetZonesDir(); + if (!zonesEtcDir.IsEmpty() && Utility::PathExists(zonesEtcDir)) + Utility::Glob(zonesEtcDir + "/*", &IncludeZoneDirRecursive, GlobDirectory); + + String zonesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones"; + if (Utility::PathExists(zonesVarDir)) + Utility::Glob(zonesVarDir + "/*", &IncludeNonLocalZone, GlobDirectory); String name, fragment; BOOST_FOREACH(boost::tie(name, fragment), ConfigFragmentRegistry::GetInstance()->GetItems()) {