#1092628 pinentry-gtk2: Gets stuck in a loop and prevents other pinentry from running if the terminal is closed when reading from terminal

Package:
pinentry-gtk2
Source:
pinentry-gtk2
Description:
GTK+-2-based PIN or pass-phrase entry dialog for GnuPG
Submitter:
Tim Connors
Date:
2025-01-10 18:18:02 UTC
Severity:
normal
#1092628#5
Date:
2025-01-10 06:14:45 UTC
From:
To:
Anything invoking this copy of pinentry (haven't verified the other
pinentry packages), if closed prematurely before a password is
accepted or rejected from the terminal, results in further invocations
being blocked for a long time (I've seen indefinitely).

For example:

This invokes the following process tree:

: 55783,20; ps axuf | grep -A2 -B2 -e [p]inentry -e [g]pg
...
tconnors   51704  0.0  0.0 499120  3224 ?        SLsl  2024   0:46  \_ /usr/bin/gpg-agent --supervised
tconnors  786820  0.8  0.0 251912 11564 ?        SLl  17:04   0:00  |   \_ pinentry
...
tconnors  786818  0.0  0.0  11288  4924 pts/337  SL+  17:04   0:00          |                           |       \_ gpg --batch --decrypt --quiet /home/tconnors/ntt/master.gpg

...

Now if I kill `gpg --batch ...`, then pinentry just spins:

tconnors   51704  0.0  0.0 499120  3224 ?        SLsl  2024   0:46  \_ /usr/bin/gpg-agent --supervised
tconnors  786820 63.2  0.0 251912 11564 ?        RLl  17:04   0:03  |   \_ pinentry

[pid 786820] gettimeofday({tv_sec=1736489157, tv_usec=122208}, NULL) = 0
[pid 786820] poll([{fd=10, events=POLLIN}], 1, 70) = 1 ([{fd=10, revents=POLLIN|POLLERR|POLLHUP}])
[pid 786820] gettimeofday({tv_sec=1736489157, tv_usec=122614}, NULL) = 0
[pid 786820] read(10, "", 1)            = 0
[pid 786820] gettimeofday({tv_sec=1736489157, tv_usec=123033}, NULL) = 0
[pid 786820] poll([{fd=10, events=POLLIN}], 1, 70) = 1 ([{fd=10, revents=POLLIN|POLLERR|POLLHUP}])
[pid 786820] gettimeofday({tv_sec=1736489157, tv_usec=123542}, NULL) = 0

One guesses that pinentry ignores SIGPIPE and/or errors and/or EOF
from the read system call.  Even though it's primarily trying to be an
X11 display, it still allows fallback to terminal, so it should cope
correctly when the terminal does terminal things.

#1092628#10
Date:
2025-01-10 07:53:50 UTC
From:
To:
Hello,

Tim Connors <reportbug@rather.puzzling.org> wrote:

IIUC, it falls back to pinentry-curses.

I think that the problem was handled by upstream:

https://dev.gnupg.org/T4585
https://dev.gnupg.org/T6641

#1092628#15
Date:
2025-01-10 18:15:10 UTC
From:
To:

Hello,

Thank you for the pointer, let's quote the essentials here to have all
information at hand:

| ... GnuPG 2.2 (which doesn't have the fix of T4585). Without the fix,
| killing gpg (by CTRL-C) causes problematic situation where pinentry
| remains asking.
[...]
| Fixed in pinentry 1.3, when using GnuPG 2.4 or later.

cu Andreas