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

From: Ulrich Mueller <[email-masked]>
Date: Thu, 16 Nov 2023 10:54:37 +0100

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 XXXXXXXXXXXXXXXX -- 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üller <[email-masked]>
   [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 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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 --pinentry-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 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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.