diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Pgp.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Pgp.php index d4c39d00f..bc0abecfd 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Pgp.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Pgp.php @@ -28,6 +28,7 @@ trait Pgp * BSD 4.4 max length = 104 */ if (80 < \strlen($homedir)) { + \clearstatcache(); // First try a symbolic link $tmpdir = \sys_get_temp_dir() . '/snappymail'; // if (\RainLoop\Utils::inOpenBasedir($tmpdir) && @@ -39,7 +40,7 @@ trait Pgp } // Else try ~/.gnupg/ + hash(email address) if (80 < \strlen($homedir)) { - $tmpdir = ($_SERVER['HOME'] ?: \exec('echo ~') ?: \dirname(getcwd())) . '/.gnupg/'; + $tmpdir = ($_SERVER['HOME'] ?: \exec('echo ~') ?: \dirname(\getcwd())) . '/.gnupg/'; if ($oAccount instanceof \RainLoop\Model\AdditionalAccount) { $tmpdir .= \sha1($oAccount->ParentEmail()); } else { @@ -50,6 +51,10 @@ trait Pgp $homedir = $link; } } + + if (104 <= \strlen($homedir . '/S.gpg-agent.extra')) { + throw new \Exception("socket name for '{$homedir}/S.gpg-agent.extra' is too long"); + } } return \SnappyMail\PGP\GnuPG::getInstance($homedir); diff --git a/snappymail/v/0.0.0/app/libraries/snappymail/pgp/gpg.php b/snappymail/v/0.0.0/app/libraries/snappymail/pgp/gpg.php index 31903845d..f4864392d 100644 --- a/snappymail/v/0.0.0/app/libraries/snappymail/pgp/gpg.php +++ b/snappymail/v/0.0.0/app/libraries/snappymail/pgp/gpg.php @@ -81,18 +81,7 @@ class GPG function __construct(string $homedir) { - $homedir = \rtrim($homedir, '/\\'); - // BSD 4.4 max length - if (104 <= \strlen($homedir . '/S.gpg-agent.extra')) { - throw new \Exception("socket name for '{$homedir}/S.gpg-agent.extra' is too long"); - } - - \clearstatcache(); - if ($homedir && !\is_dir($homedir) && !\mkdir($homedir, 0700, true)) { - throw new \Exception("mkdir({$homedir}) failed"); - } - - $this->options['homedir'] = $homedir; + $this->options['homedir'] = \rtrim($homedir, '/\\'); // the random seed file makes subsequent actions faster so only disable it if we have to. if ($this->options['homedir'] && !\is_writeable($this->options['homedir'])) {