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