feat(config): Allow defining config.php permissions after write

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2026-02-17 15:25:47 +01:00
parent f2907f133c
commit af9308344b
No known key found for this signature in database
GPG key ID: F72FA5B49FFA96B0
2 changed files with 10 additions and 2 deletions

View file

@ -2613,6 +2613,13 @@ $CONFIG = [
*/
'data-fingerprint' => '',
/**
* config.php file mode in octal notation.
*
* Defaults to ``0640`` (writable by user, readable by group).
*/
'configfilemode' => 0640,
/**
* This entry serves as a warning if the sample configuration was copied.
* DO NOT ADD THIS TO YOUR CONFIGURATION!

View file

@ -276,8 +276,9 @@ class Config {
touch($this->configFilePath);
$filePointer = fopen($this->configFilePath, 'r+');
// Prevent others not to read the config
chmod($this->configFilePath, 0640);
// Apply permissions for config.php, defaulting to user read-write and group read
$permissions = $this->cache['configfilemode'] ?? 0640;
chmod($this->configFilePath, $permissions);
// File does not exist, this can happen when doing a fresh install
if (!is_resource($filePointer)) {