Subject: Re: bug#67012: 29.1; epa-sign-file pinentry loopback mode does not work with S/MIME

From: Ulrich Mueller <[email-masked]>
Date: Fri, 17 Nov 2023 12:40:05 +0100

Until there's a proper fix (not anytime soon, I suppose?), could we
please disable pinentry loopback with gpgsm? See patch below.

That way, the user could still set epg-pinentry-mode to loopback for use
with gpg2, and with gpgsm it would fall back to passphrase input through
the pinentry program (i.e. in the GUI). This seems to be better than
erroring out.

(In fact, I use gpgsm with pinentry.el from Emacs 25.3 as a workaround.
Unfortunately, that package has been removed as a fix for bug #27445.)

>From b1cbdfc8f4890c6cb31cc8d59b347aedfb2f7f5d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ulrich=20M=C3=BCller?= <[email-masked]>
Date: Fri, 17 Nov 2023 12:16:54 +0100
Subject: [PATCH] Don't enable pinentry loopback mode for gpgsm

* lisp/epg.el (epg--start): Passphrase entry through the
minibuffer is currently not supported with gpgsm, therefore don't
pass "--pinentry-mode loopback" as an argument when the protocol
is CMS.  (Bug#67012)
---
 lisp/epg.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/epg.el b/lisp/epg.el
index aae9b9444b4..b994c1b9ca2 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -595,7 +595,12 @@ 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)
+				(not
+				 ;; loopback doesn't work with gpgsm
+				 (and (eq (epg-context-protocol context) 'CMS)
+				      (eq (epg-context-pinentry-mode context)
+					  'loopback))))
 			   (list "--pinentry-mode"
 				 (symbol-name (epg-context-pinentry-mode
 					       context))))
-- 
2.42.1