mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
Guard FileCache against an existing but not writeable runtime path
fixes #10123
This commit is contained in:
parent
6f7e0890d8
commit
045e4a99b5
@ -41,21 +41,18 @@ class FileCache
|
|||||||
protected function __construct($name)
|
protected function __construct($name)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$tmpdir = sys_get_temp_dir();
|
$tmpDir = sys_get_temp_dir();
|
||||||
$basedir = $tmpdir . '/FileCache_' . $name;
|
$runtimePath = $tmpDir . '/FileCache_' . $name;
|
||||||
|
if (is_dir($runtimePath)) {
|
||||||
if (file_exists($basedir) && is_writeable($basedir)) {
|
// 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
|
||||||
$this->basedir = $basedir;
|
if (is_writeable($runtimePath)) {
|
||||||
$this->enabled = true;
|
$this->basedir = $runtimePath;
|
||||||
|
|
||||||
} elseif (file_exists($tmpdir) && is_writeable($tmpdir)) {
|
|
||||||
|
|
||||||
if (mkdir($basedir, '0750', true)) {
|
|
||||||
$this->enabled = true;
|
$this->enabled = true;
|
||||||
$this->basedir = $basedir;
|
|
||||||
}
|
}
|
||||||
|
} elseif (is_dir($tmpDir) && is_writeable($tmpDir) && mkdir($runtimePath, '0750', true)) {
|
||||||
|
$this->basedir = $runtimePath;
|
||||||
|
$this->enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user