Guard FileCache against an existing but not writeable runtime path
fixes #10123
This commit is contained in:
parent
6f7e0890d8
commit
045e4a99b5
library/Icinga/Web
|
@ -41,21 +41,18 @@ class FileCache
|
|||
protected function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
$tmpdir = sys_get_temp_dir();
|
||||
$basedir = $tmpdir . '/FileCache_' . $name;
|
||||
|
||||
if (file_exists($basedir) && is_writeable($basedir)) {
|
||||
|
||||
$this->basedir = $basedir;
|
||||
$this->enabled = true;
|
||||
|
||||
} elseif (file_exists($tmpdir) && is_writeable($tmpdir)) {
|
||||
|
||||
if (mkdir($basedir, '0750', true)) {
|
||||
$tmpDir = sys_get_temp_dir();
|
||||
$runtimePath = $tmpDir . '/FileCache_' . $name;
|
||||
if (is_dir($runtimePath)) {
|
||||
// Don't combine the following if with the above because else mkdir may fail w/ file exists if the runtime
|
||||
// path exists and is not writeable
|
||||
if (is_writeable($runtimePath)) {
|
||||
$this->basedir = $runtimePath;
|
||||
$this->enabled = true;
|
||||
$this->basedir = $basedir;
|
||||
}
|
||||
|
||||
} elseif (is_dir($tmpDir) && is_writeable($tmpDir) && mkdir($runtimePath, '0750', true)) {
|
||||
$this->basedir = $runtimePath;
|
||||
$this->enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue