From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Ulrich Mueller <ulm@gentoo.org>
Newsgroups: gmane.emacs.bugs
Subject: bug#67012: 29.1;
 epa-sign-file pinentry loopback mode does not work with S/MIME
Date: Thu, 16 Nov 2023 10:54:37 +0100
Message-ID: <u34x6nhuq@gentoo.org>
References: <u4jhvqus0@gentoo.org> <83jzqjqfma.fsf@gnu.org>
 <87leaz9hrv.fsf@gmx.de> <83h6lnq7y7.fsf@gnu.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="21708"; mail-complaints-to="usenet@ciao.gmane.io"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cc: 67012@debbugs.gnu.org, Michael Albinus <michael.albinus@gmx.de>
To: Eli Zaretskii <eliz@gnu.org>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 16 10:56:40 2023
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
	by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
	(Exim 4.92)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1r3Z72-0005Vg-4J
	for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 16 Nov 2023 10:56:40 +0100
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-gnu-emacs-bounces@gnu.org>)
	id 1r3Z6a-0003T3-I0; Thu, 16 Nov 2023 04:56:12 -0500
Original-Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1r3Z6R-0003SH-QL
 for bug-gnu-emacs@gnu.org; Thu, 16 Nov 2023 04:56:04 -0500
Original-Received: from debbugs.gnu.org ([2001:470:142:5::43])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1r3Z6R-0008NC-Do
 for bug-gnu-emacs@gnu.org; Thu, 16 Nov 2023 04:56:03 -0500
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1r3Z6Q-0000R4-UR
 for bug-gnu-emacs@gnu.org; Thu, 16 Nov 2023 04:56:02 -0500
X-Loop: help-debbugs@gnu.org
Resent-From: Ulrich Mueller <ulm@gentoo.org>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Thu, 16 Nov 2023 09:56:02 +0000
Resent-Message-ID: <handler.67012.B67012.17001285031561@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 67012
X-GNU-PR-Package: emacs
Original-Received: via spool by 67012-submit@debbugs.gnu.org id=B67012.17001285031561
 (code B ref 67012); Thu, 16 Nov 2023 09:56:02 +0000
Original-Received: (at 67012) by debbugs.gnu.org; 16 Nov 2023 09:55:03 +0000
Original-Received: from localhost ([127.0.0.1]:54495 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1r3Z5S-0000P7-Go
 for submit@debbugs.gnu.org; Thu, 16 Nov 2023 04:55:03 -0500
Original-Received: from dev.gentoo.org ([2001:470:ea4a:1:5054:ff:fec7:86e4]:38781
 helo=smtp.gentoo.org) by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ulm@gentoo.org>) id 1r3Z5E-0000OE-UH
 for 67012@debbugs.gnu.org; Thu, 16 Nov 2023 04:55:01 -0500
In-Reply-To: <83h6lnq7y7.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 15 Nov
 2023 18:48:00 +0200")
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Xref: news.gmane.io gmane.emacs.bugs:274448
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/274448>

When executing gpg2 from the command line, but with the same arguments
that are passed from Emacs, I see the following output:

   $ /usr/bin/gpg2 --no-tty --status-fd 1 --yes --enable-progress-filter --=
command-fd 0 --output hello.txt.gpg --pinentry-mode loopback --sign -u XXXX=
XXXXXXXXXXXX -- hello.txt 2>/dev/null
   [GNUPG:] KEYEXPIRED 1546257620
   [GNUPG:] KEYEXPIRED 1533081541
   [GNUPG:] KEY_CONSIDERED XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0
   [GNUPG:] PROGRESS hello.txt ? 0 6 B
   [GNUPG:] BEGIN_SIGNING H8
   [GNUPG:] PROGRESS hello.txt ? 6 6 B
   [GNUPG:] USERID_HINT XXXXXXXXXXXXXXXX Ulrich M=C3=BCller <ulm@gentoo.org>
   [GNUPG:] NEED_PASSPHRASE XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 1 0
   [GNUPG:] INQUIRE_MAXLEN 100
   [GNUPG:] GET_HIDDEN passphrase.enter
   ****  <-- passphrase input
   [GNUPG:] GOT_IT
   [GNUPG:] SIG_CREATED S 1 8 00 1700077951 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=
XXXXXXXXX

IIUC, function epg--process-filter looks for status output from GnuPG
and calls the matching epg--status-* functions. The passphrase is read
in epg--status-GET_HIDDEN.


For gpgsm (same arguments as passed from Emacs, plus --passphrase-fd 0)
output is this:

   $ /usr/bin/gpgsm --no-tty --status-fd 1 --yes --output hello.txt.p7m --p=
inentry-mode loopback --passphrase-fd 0 --sign -u XXXXXXXXXXXXXXXX -- hello=
.txt 2>/dev/null
   ****  <-- passphrase input
   [GNUPG:] PROGRESS starting_agent ? 0 0
   [GNUPG:] SIG_CREATED S 1 8 00 20231115T195756 XXXXXXXXXXXXXXXXXXXXXXXXXX=
XXXXXXXXXXXXXX

Note that gpgsm is way less chatty than gpg2. Especially, the passphrase
is expected before the first status message appears, and function
epg--status-GET_HIDDEN is never called. So this would have to be handled
in a different way.