Skip to content

Commit

Permalink
Adding the ability to set the permissions used when creating files
Browse files Browse the repository at this point in the history
previously this was hardcoded, meaning that if you wanted to configure
to permit group access (for exammple) this wasn't possible
  • Loading branch information
mintsoft committed Jan 11, 2025
1 parent 8bf4727 commit 463670b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ protected function defaultValues() : array
'admin_login' => array('admin', 'Login and password for web admin panel'),
'admin_password' => array(''),
'admin_totp' => array(''),
'file_permissions' => array('0600', 'permissions to chmod cache files to when creating'),
'dir_permissions' => array('0700', 'permissions to chmod cache directories to when creating'),
'insecure_cryptkey' => array(false, 'Use email address instead of login password for encrypting sensitive data (like account passwords)'),

'force_https' => array(false),
Expand Down
4 changes: 2 additions & 2 deletions snappymail/v/0.0.0/app/libraries/RainLoop/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ public static function inOpenBasedir(string $name) : string
public static function saveFile(string $filename, string $data) : void
{
$dir = \dirname($filename);
if (!\is_dir($dir) && !\mkdir($dir, 0700, true)) {
if (!\is_dir($dir) && !\mkdir($dir, intval($oConfig->Get('security', 'dir_permissions)), true)) {
throw new \RuntimeException('Failed to create directory "'.$dir.'"');
}
if (false === \file_put_contents($filename, $data)) {
throw new \RuntimeException('Failed to save file "'.$filename.'"');
}
\clearstatcache();
\chmod($filename, 0600);
\chmod($filename, intval($oConfig->Get('security', 'file_permissions')));
/*
try {
} catch (\Throwable $oException) {
Expand Down

0 comments on commit 463670b

Please sign in to comment.