Package: alot
Version: 0.3.4-1
Severity: normal
tag: patch

Dear Maintainer,

There was a bug in gpg signing part of alot which was failing when
gpg-agent is either not running or password is not present in agent
(mostly due to the improper configuration of gpg-agent). Here alot was
not properly doing error handling and was not displaying proper error
message display.

I discussed this with upstream author and he provided a fix which is
already on upstream Git but I'm attaching same patch with this mail.

Please consider applying this patch to the alot package till upstream
releases new tarball with this fix.

[1] https://github.com/pazz/alot/issues/590



-- System Information:
Debian Release: 7.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
armel

Kernel: Linux 3.7-trunk-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_IN, LC_CTYPE=en_IN (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages alot depends on:
ii  python            2.7.3-4
ii  python-configobj  4.7.2+ds-4
ii  python-gpgme      0.2-3
ii  python-magic      1:5.11-3
ii  python-notmuch    0.15.2-1
ii  python-twisted    12.3.0-1
ii  python-urwid      1.1.0-1

Versions of packages alot recommends:
ii  notmuch  0.15.2-1

Versions of packages alot suggests:
ii  alot-doc  0.3.4-1

-- no debconf information

-- 
Vasudev Kamath
http://copyninja.info
Connect on ~friendica: copyninja@{frndk.de | vasudev.homelinux.net}
IRC nick: copyninja | vasudev {irc.oftc.net | irc.freenode.net}
GPG Key: C517 C25D E408 759D 98A4  C96B 6C8F 74AE 8770 0B7E
From a1fc6b97b9d3975a3d0239f5e66ea2b78c53a43d Mon Sep 17 00:00:00 2001
From: Patrick Totzke <patricktot...@gmail.com>
Date: Sat, 6 Apr 2013 13:25:51 +0100
Subject: fix incorrect instanciations of GPGProblem

with missing 'code' parameter.
cf issue #590
---
 alot/db/envelope.py |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/alot/db/envelope.py b/alot/db/envelope.py
index f0c94de..0f8c195 100644
--- a/alot/db/envelope.py
+++ b/alot/db/envelope.py
@@ -18,7 +18,7 @@ import alot.helper as helper
 import alot.crypto as crypto
 import gpgme
 from alot.settings import settings
-from alot.errors import GPGProblem
+from alot.errors import GPGProblem, GPGCode
 
 from attachment import Attachment
 from utils import encode_header
@@ -192,8 +192,9 @@ class Envelope(object):
                 signatures, signature_str = crypto.detached_signature_for(
                     plaintext, self.sign_key)
                 if len(signatures) != 1:
-                    raise GPGProblem(("Could not sign message "
-                                      "(GPGME did not return a signature)"))
+                    raise GPGProblem("Could not sign message (GPGME "
+                                     "did not return a signature)",
+                                     code=GPGCode.KEY_CANNOT_SIGN)
             except gpgme.GpgmeError as e:
                 if e.code == gpgme.ERR_BAD_PASSPHRASE:
                     # If GPG_AGENT_INFO is unset or empty, the user just does
@@ -201,11 +202,12 @@ class Envelope(object):
                     if os.environ.get('GPG_AGENT_INFO', '').strip() == '':
                         msg = "Got invalid passphrase and GPG_AGENT_INFO\
                                 not set. Please set up gpg-agent."
-                        raise GPGProblem(msg)
+                        raise GPGProblem(msg, code=GPGCode.BAD_PASSPHRASE)
                     else:
-                        raise GPGProblem(("Bad passphrase. Is "
-                                          "gpg-agent running?"))
-                raise GPGProblem(str(e))
+                        raise GPGProblem("Bad passphrase. Is gpg-agent "
+                                         "running?",
+                                         code=GPGCode.BAD_PASSPHRASE)
+                raise GPGProblem(str(e), code=GPGCode.KEY_CANNOT_SIGN)
 
             micalg = crypto.RFC3156_micalg_from_algo(signatures[0].hash_algo)
             unencrypted_msg = MIMEMultipart('signed', micalg=micalg,
@@ -235,7 +237,7 @@ class Envelope(object):
                 encrypted_str = crypto.encrypt(plaintext,
                                                self.encrypt_keys.values())
             except gpgme.GpgmeError as e:
-                raise GPGProblem(str(e))
+                raise GPGProblem(str(e), code=GPGCode.KEY_CANNOT_ENCRYPT)
 
             outer_msg = MIMEMultipart('encrypted',
                                       protocol='application/pgp-encrypted')
-- 
1.7.10.4

Attachment: signature.asc
Description: Digital signature

Reply via email to