Skip to content

Commit

Permalink
Enigma: Add enigma_debug option
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Apr 17, 2016
1 parent e2e5626 commit 6e4642b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CHANGELOG Roundcube Webmail
===========================

- Enigma: Added enigma_debug option

RELEASE 1.2-rc
--------------
- Managesieve: Refactored script parser to be 100x faster
Expand Down
2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ REQUIREMENTS
- Net_IDNA2 0.1.1 or newer
- Auth_SASL 1.0.6 or newer
- Net_Sieve 1.3.2 or newer (for managesieve plugin)
- Crypt_GPG 1.4.0 or newer (for enigma plugin)
- Crypt_GPG 1.4.1 or newer (for enigma plugin)
* php.ini options (see .htaccess file):
- error_reporting E_ALL & ~E_NOTICE (or lower)
- memory_limit > 16MB (increase as suitable to support large attachments)
Expand Down
2 changes: 1 addition & 1 deletion composer.json-dist
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"pear-pear.php.net/net_idna2": "~0.1.1",
"pear-pear.php.net/mail_mime": "~1.10.0",
"pear-pear.php.net/net_smtp": "~1.7.1",
"pear-pear.php.net/crypt_gpg": "~1.4.0",
"pear-pear.php.net/crypt_gpg": "~1.4.1",
"roundcube/net_sieve": "~1.5.0"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/enigma/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"require": {
"php": ">=5.3.0",
"roundcube/plugin-installer": "~0.1.6",
"pear-pear.php.net/crypt_gpg": "~1.4.0"
"pear-pear.php.net/crypt_gpg": "~1.4.1"
}
}
3 changes: 3 additions & 0 deletions plugins/enigma/config.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ $config['enigma_pgp_driver'] = 'gnupg';
// A driver to use for S/MIME. Default: "phpssl".
$config['enigma_smime_driver'] = 'phpssl';

// Enables logging of enigma operations (including Crypt_GPG debug info)
$config['enigma_debug'] = false;

// Keys directory for all users. Default 'enigma/home'.
// Must be writeable by PHP process
$config['enigma_pgp_homedir'] = null;
Expand Down
14 changes: 12 additions & 2 deletions plugins/enigma/lib/enigma_driver_gnupg.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function __construct($user)
function init()
{
$homedir = $this->rc->config->get('enigma_pgp_homedir', INSTALL_PATH . 'plugins/enigma/home');
$debug = $this->rc->config->get('enigma_debug');

if (!$homedir)
return new enigma_error(enigma_error::INTERNAL,
Expand Down Expand Up @@ -73,7 +74,7 @@ function init()
$this->gpg = new Crypt_GPG(array(
'homedir' => $this->homedir,
// 'binary' => '/usr/bin/gpg2',
// 'debug' => true,
'debug' => $debug ? array($this, 'debug') : false,
));
}
catch (Exception $e) {
Expand Down Expand Up @@ -257,10 +258,11 @@ public function get_key($keyid)
public function gen_key($data)
{
try {
$debug = $this->rc->config->get('enigma_debug');
$keygen = new Crypt_GPG_KeyGenerator(array(
'homedir' => $this->homedir,
// 'binary' => '/usr/bin/gpg2',
// 'debug' => true,
'debug' => $debug ? array($this, 'debug') : false,
));

$key = $keygen
Expand Down Expand Up @@ -441,4 +443,12 @@ protected function parse_key($key)

return $ekey;
}

/**
* Write debug info from Crypt_GPG to logs/enigma
*/
public function debug($line)
{
rcube::write_log('enigma', 'GPG: ' . $line);
}
}

3 comments on commit 6e4642b

@CRtEurope
Copy link

@CRtEurope CRtEurope commented on 6e4642b Jun 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple question.
It's about the lines 76 and 264 in plugins/enigma/lib/enigma_driver_gnupg.php.
Why is the setting 'binary' => '/usr/bin/gpg2', not set as default setting?
I have set it as default setting and everything works great.

Thanks in advance

@alecpl
Copy link
Member Author

@alecpl alecpl commented on 6e4642b Jun 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because there are still systems with no gnupg 2. Also, there are systems with gnupg 2.1 which is not supported, so better to fallback to the default in such cases.
At some point we may provide a config option for this. Currently Crypt_GPG will auto-detect gnupg binary location.

@CRtEurope
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarification. But on my system it's not autodetected and also v1 installed that's why I enabled gpg2.. Crypt_GPG detects v1 only.

Thanks again

Please sign in to comment.