Enigma: Add possibility to configure gpg binary location (enigma_pgp_binary)

pull/5268/merge
Aleksander Machniak 8 years ago
parent b9d3fb0221
commit 13b76d9b1e

@ -21,6 +21,7 @@ CHANGELOG Roundcube Webmail
- Fix bug where "no body" alert could be displayed when sending mailvelope email
- Enigma: Fix keys import from inside of an encrypted message (#5285)
- Enigma: Fix malformed signed messages with force_7bit=true (#5292)
- Enigma: Add possibility to configure gpg binary location (enigma_pgp_binary)
- Fix searching by email address in contacts with multiple addresses (#5291)
- Fix handling of --delete argument in moduserprefs.sh script (#5296)
- Workaround PHP issue by calling closelog() on script shutdown when using log_driver=syslog (#5289)

@ -16,6 +16,10 @@ $config['enigma_debug'] = false;
// Must be writeable by PHP process
$config['enigma_pgp_homedir'] = null;
// Location of gpg binary. By default it will be auto-detected.
// This is also a way to force gpg2 use if there are both 1.x and 2.x on the system.
$config['enigma_pgp_binary'] = '';
// Enables signatures verification feature.
$config['enigma_signatures'] = true;

@ -41,41 +41,53 @@ class enigma_driver_gnupg extends enigma_driver
{
$homedir = $this->rc->config->get('enigma_pgp_homedir', INSTALL_PATH . 'plugins/enigma/home');
$debug = $this->rc->config->get('enigma_debug');
$binary = $this->rc->config->get('enigma_pgp_binary');
if (!$homedir)
if (!$homedir) {
return new enigma_error(enigma_error::INTERNAL,
"Option 'enigma_pgp_homedir' not specified");
}
// check if homedir exists (create it if not) and is readable
if (!file_exists($homedir))
if (!file_exists($homedir)) {
return new enigma_error(enigma_error::INTERNAL,
"Keys directory doesn't exists: $homedir");
if (!is_writable($homedir))
}
if (!is_writable($homedir)) {
return new enigma_error(enigma_error::INTERNAL,
"Keys directory isn't writeable: $homedir");
}
$homedir = $homedir . '/' . $this->user;
// check if user's homedir exists (create it if not) and is readable
if (!file_exists($homedir))
if (!file_exists($homedir)) {
mkdir($homedir, 0700);
}
if (!file_exists($homedir))
if (!file_exists($homedir)) {
return new enigma_error(enigma_error::INTERNAL,
"Unable to create keys directory: $homedir");
if (!is_writable($homedir))
}
if (!is_writable($homedir)) {
return new enigma_error(enigma_error::INTERNAL,
"Unable to write to keys directory: $homedir");
}
$this->homedir = $homedir;
$options = array('homedir' => $this->homedir);
if ($debug) {
$options['debug'] = array($this, 'debug');
}
if ($binary) {
$options['binary'] = $binary;
}
// Create Crypt_GPG object
try {
$this->gpg = new Crypt_GPG(array(
'homedir' => $this->homedir,
// 'binary' => '/usr/bin/gpg2',
'debug' => $debug ? array($this, 'debug') : false,
));
$this->gpg = new Crypt_GPG($options);
}
catch (Exception $e) {
return $this->get_error_from_exception($e);

Loading…
Cancel
Save