From f0fa9324d83ea1bd57f0b702e3b419f7194169cb Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 21 Apr 2016 02:13:52 -0400
Subject: [PATCH] Merge branch 'master' of github.com:roundcube/roundcubemail

---
 plugins/enigma/lib/enigma_driver_gnupg.php |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/plugins/enigma/lib/enigma_driver_gnupg.php b/plugins/enigma/lib/enigma_driver_gnupg.php
index 5ddf724..9a8e59e 100644
--- a/plugins/enigma/lib/enigma_driver_gnupg.php
+++ b/plugins/enigma/lib/enigma_driver_gnupg.php
@@ -40,6 +40,7 @@
     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,
@@ -73,7 +74,7 @@
             $this->gpg = new Crypt_GPG(array(
                 'homedir'   => $this->homedir,
                 // 'binary'    => '/usr/bin/gpg2',
-                // 'debug'     => true,
+                'debug'     => $debug ? array($this, 'debug') : false,
           ));
         }
         catch (Exception $e) {
@@ -257,10 +258,11 @@
     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
@@ -441,4 +443,12 @@
 
         return $ekey;
     }
+
+    /**
+     * Write debug info from Crypt_GPG to logs/enigma
+     */
+    public function debug($line)
+    {
+        rcube::write_log('enigma', 'GPG: ' . $line);
+    }
 }

--
Gitblit v1.9.1