GNU bug report logs - #23619
Some epg tests fail

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Wed, 25 May 2016 17:02:01 UTC

Severity: minor

Found in version 25.1.50

Fixed in version 26.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: npostavs <at> users.sourceforge.net
To: Daiki Ueno <ueno <at> gnu.org>
Cc: 23619 <at> debbugs.gnu.org, Glenn Morris <rgm <at> gnu.org>
Subject: bug#23619: Some epg tests fail
Date: Sun, 19 Feb 2017 15:35:32 -0500
[Message part 1 (text/plain, inline)]
Daiki Ueno <ueno <at> gnu.org> writes:

> npostavs <at> users.sourceforge.net writes:
>
>>
>> These tests popup a dialog box to enter a passphrase before failing.
>> The following patch which sets pinentry mode to 'loopback' fixes it for
>> me (I have not tested with other gpg versions though):
>
> Thank you.  That sounds like a good idea, but the version actually
> matters: gpg 1.x and 2.0.x refuse the --pinentry-mode option and exit
> abnormally...
>
> Maybe you could add a version check around the call (or in epg--start)?
> epg-config.el provides a few functions to do that.

Does this look right?

[v2-0001-Fix-passphrase-callback-with-gpg-2.1-Bug-23619.patch (text/x-diff, inline)]
From 9cd6f55d3d01fe0781ce81b2e394ed3e8febd6fa Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sun, 19 Feb 2017 10:34:50 -0500
Subject: [PATCH v2] Fix passphrase callback with gpg 2.1+ (Bug#23619)

* lisp/epg.el (epg-context-set-passphrase-callback): Set CONTEXT's
pinentry mode to `loopback'.
(epg--start): Only pass `--pinentry-mode' for gpg 2.1+.
---
 lisp/epg.el | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/lisp/epg.el b/lisp/epg.el
index 587271b000..ba7125f232 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -246,16 +246,15 @@ epg-context-set-passphrase-callback
 The function gets three arguments: the context, the key-id in
 question, and the callback data (if any).
 
-The callback may not be called if you use GnuPG 2.x, which relies
-on the external program called `gpg-agent' for passphrase query.
-If you really want to intercept passphrase query, consider
-installing GnuPG 1.x _along with_ GnuPG 2.x, which does passphrase
-query by itself and Emacs can intercept them."
+Also set CONTEXT's pinentry mode to `loopback' (when using GnuPG
+2.x, the callback would not be called otherwise)."
   ;; (declare (obsolete setf "25.1"))
   (setf (epg-context-passphrase-callback context)
         (if (functionp passphrase-callback)
 	    (list passphrase-callback)
-	  passphrase-callback)))
+	  passphrase-callback))
+  (when passphrase-callback
+    (setf (epg-context-pinentry-mode context) 'loopback)))
 
 (defun epg-context-set-progress-callback (context
 					  progress-callback)
@@ -578,7 +577,13 @@ epg--start
 		       (if (epg-context-textmode context) '("--textmode"))
 		       (if (epg-context-output-file context)
 			   (list "--output" (epg-context-output-file context)))
-		       (if (epg-context-pinentry-mode context)
+		       (if (and (epg-context-pinentry-mode context)
+                                ;; GPG 1.x and 2.0.x reject `--pinentry-mode'.
+                                (version<= "2.1"
+                                           (alist-get
+                                            'version (epg-find-configuration
+                                                      (epg-context-protocol context))
+                                            "1.0")))
 			   (list "--pinentry-mode"
 				 (symbol-name (epg-context-pinentry-mode
 					       context))))
-- 
2.11.1


This bug report was last modified 8 years and 7 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.