Core/Config - Use new File::file_put_contents() method to enforce access rights on backups and set initial access rights of the backup dir upon creation.

This commit is contained in:
Ad Schellevis 2023-09-04 20:34:52 +02:00
parent 8b7f6bab4e
commit 8a4f77bbd1

View File

@ -546,6 +546,7 @@ class Config extends Singleton
if (!file_exists($target_dir)) {
// create backup directory if it is missing
mkdir($target_dir);
chmod($target_dir, 0750);
}
if (file_exists($target_dir . "config-" . $timestamp . ".xml")) {
// The new target backup filename shouldn't exists, because of the use of microtime.
@ -555,7 +556,7 @@ class Config extends Singleton
} else {
$target_filename = "config-" . $timestamp . ".xml";
}
copy($this->config_file, $target_dir . $target_filename);
File::file_put_contents($target_dir . $target_filename, file_get_contents($this->config_file), 0640);
return $target_dir . $target_filename;
}