mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Resolve #1660
This commit is contained in:
parent
57d1021d51
commit
95436347e5
|
@ -722,4 +722,19 @@ abstract class Utils
|
|||
$aParts[] = $sDomain;
|
||||
return \implode('@', $aParts);
|
||||
}
|
||||
|
||||
public static function mkdir(string $directory) : void
|
||||
{
|
||||
if (!\is_dir($directory)) {
|
||||
if (!\mkdir($directory, 0700, true)) {
|
||||
throw new \RuntimeException("Failed to create directory {$directory}");
|
||||
}
|
||||
\clearstatcache();
|
||||
}
|
||||
/*
|
||||
if (!\is_writable($directory)) {
|
||||
throw new \Exception("Failed to access directory {$directory}");
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ class File implements \MailSo\Cache\DriverInterface
|
|||
function __construct(string $sCacheFolder)
|
||||
{
|
||||
$this->sCacheFolder = \rtrim(\trim($sCacheFolder), '\\/').'/';
|
||||
\MailSo\Base\Utils::mkdir($this->sCacheFolder);
|
||||
|
||||
// http://www.brynosaurus.com/cachedir/
|
||||
$tag = $this->sCacheFolder . 'CACHEDIR.TAG';
|
||||
|
|
|
@ -59,9 +59,7 @@ trait Pgp
|
|||
\RainLoop\Providers\Storage\Enumerations\StorageType::ROOT
|
||||
), '/') . '/.gnupg';
|
||||
|
||||
if (!\is_dir($homedir)) {
|
||||
\mkdir($homedir, 0700, true);
|
||||
}
|
||||
\MailSo\Base\Utils::mkdir($homedir);
|
||||
if (!\is_writable($homedir)) {
|
||||
throw new \Exception("gpg homedir '{$homedir}' not writable");
|
||||
}
|
||||
|
|
|
@ -22,9 +22,7 @@ trait SMime
|
|||
\RainLoop\Providers\Storage\Enumerations\StorageType::ROOT
|
||||
), '/') . '/.smime';
|
||||
|
||||
if (!\is_dir($homedir)) {
|
||||
\mkdir($homedir, 0700, true);
|
||||
}
|
||||
\MailSo\Base\Utils::mkdir($homedir);
|
||||
if (!\is_writable($homedir)) {
|
||||
throw new \Exception("smime homedir '{$homedir}' not writable");
|
||||
}
|
||||
|
|
|
@ -147,9 +147,7 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
|
|||
.($sSubEmail ? '/'.\MailSo\Base\Utils::SecureFileName($sSubEmail) : '')
|
||||
.'/.files/'.\sha1($sKey);
|
||||
|
||||
if ($bMkDir && !\is_dir(\dirname($sFilePath)) && !\mkdir(\dirname($sFilePath), 0700, true)) {
|
||||
throw new \RuntimeException('Can\'t make storage directory "'.$sFilePath.'"');
|
||||
}
|
||||
$bMkDir && \MailSo\Base\Utils::mkdir(\dirname($sFilePath));
|
||||
|
||||
return $sFilePath;
|
||||
}
|
||||
|
|
|
@ -143,10 +143,7 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
|||
}
|
||||
}
|
||||
|
||||
if ($bMkDir && !empty($sFilePath) && !\is_dir($sFilePath) && !\mkdir($sFilePath, 0700, true))
|
||||
{
|
||||
throw new \RuntimeException('Can\'t make storage directory "'.$sFilePath.'"');
|
||||
}
|
||||
$bMkDir && !empty($sFilePath) && \MailSo\Base\Utils::mkdir($sFilePath);
|
||||
|
||||
return $sFilePath;
|
||||
}
|
||||
|
|
|
@ -10,13 +10,7 @@ class Temporary
|
|||
{
|
||||
$tmpdir = \sys_get_temp_dir() . '/snappymail';
|
||||
// if (\RainLoop\Utils::inOpenBasedir($tmpdir) &&
|
||||
\is_dir($tmpdir) || \mkdir($tmpdir, 0700);
|
||||
if (!\is_dir($tmpdir)) {
|
||||
throw new \Exception("Failed to create directory {$tmpdir}");
|
||||
}
|
||||
if (!\is_writable($tmpdir)) {
|
||||
// throw new \Exception("Failed to access directory {$tmpdir}");
|
||||
}
|
||||
\MailSo\Base\Utils::mkdir($tmpdir);
|
||||
if ($prefix) {
|
||||
$this->filename = @\tempnam($tmpdir, $name);
|
||||
} else {
|
||||
|
|
|
@ -17,6 +17,7 @@ abstract class Upgrade
|
|||
$sNewDir = $sDataPath
|
||||
.'/'.\MailSo\Base\Utils::SecureFileName($sDomain ?: 'unknown.tld')
|
||||
.'/'.\MailSo\Base\Utils::SecureFileName(\implode('@', $aEmail) ?: '.unknown');
|
||||
// \MailSo\Base\Utils::mkdir($sNewDir)
|
||||
if (\is_dir($sNewDir) || \mkdir($sNewDir, 0700, true)) {
|
||||
foreach (\glob("{$sDomainDir}/*") as $sItem) {
|
||||
$sName = \basename($sItem);
|
||||
|
|
Loading…
Reference in a new issue