diff --git a/library/Icinga/Security/Csp/Loader/DashboardCspLoader.php b/library/Icinga/Security/Csp/Loader/DashboardCspLoader.php index ffabb5374..3d2461ed1 100644 --- a/library/Icinga/Security/Csp/Loader/DashboardCspLoader.php +++ b/library/Icinga/Security/Csp/Loader/DashboardCspLoader.php @@ -90,11 +90,14 @@ class DashboardCspLoader implements CspLoader if ($this->allUsers) { $result = []; - foreach (new DirectoryIterator(Config::resolvePath('dashboards')) as $dir) { + $dashboardsDir = Config::resolvePath('dashboards'); + if (! is_dir($dashboardsDir)) { + return $result; + } + foreach (new DirectoryIterator($dashboardsDir) as $dir) { if ($dir->isDot() || ! $dir->isDir()) { continue; } - $user = new User($dir->getFilename()); $result = array_merge($result, $this->loadForUser($user)); } diff --git a/library/Icinga/Security/Csp/Loader/NavigationCspLoader.php b/library/Icinga/Security/Csp/Loader/NavigationCspLoader.php index 208e270d0..a82c9e2cf 100644 --- a/library/Icinga/Security/Csp/Loader/NavigationCspLoader.php +++ b/library/Icinga/Security/Csp/Loader/NavigationCspLoader.php @@ -117,12 +117,14 @@ class NavigationCspLoader implements CspLoader if ($this->allUsers) { foreach ($navigationTypes as $type => $typeConfig) { $result = array_merge($result, $this->loadConfig($type, $typeConfig)); - - foreach (new DirectoryIterator(Config::resolvePath('preferences')) as $userDir) { + $preferencesDir = Config::resolvePath('preferences'); + if (! is_dir($preferencesDir)) { + continue; + } + foreach (new DirectoryIterator($preferencesDir) as $userDir) { if ($userDir->isDot() || ! $userDir->isDir()) { continue; } - $result = array_merge($result, $this->loadConfig($type, $typeConfig, $userDir->getFilename())); } }