Bug 805342 - F16-xfce4 pinentry-gtk-2 consumes CPU, does not fall back to pinentry-curses.
F16-xfce4 pinentry-gtk-2 consumes CPU, does not fall back to pinentry-curses.
Product: Fedora
Classification: Fedora
Component: pinentry (Show other bugs)
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Rex Dieter
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2012-03-20 19:40 EDT by Christopher R. Hertel
Modified: 2014-09-28 20:21 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-02-13 19:29:58 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Christopher R. Hertel 2012-03-20 19:40:01 EDT
Description of problem:

pinentry-gtk-2 fails to drop down to pinentry-curses if no X display is available.  Instead, it consumes all available CPU and must be -KILLed.

If an X display is available via ssh port forwarding, pinentry-gtk-2 fails to use the forwarded display.

The combination of factors means that it is impossible to use gpg2 over a remote connection (e.g., via ssh).

Version-Release number of selected component (if applicable):

* Fedora 16 XFCE spin
* 3.2.10-3.fc16.x86_64
* gpg2 (GnuPG) 2.0.18
* gpg-agent (GnuPG) 2.0.18
* pinentry-gtk2 0.8.1
* pinentry-curses (pinentry) 0.8.1
* All updates applied as of 20-Mar-2012

How reproducible:

Attempt to decrypt a PGP encrypted file from a non-X terminal session, e.g., a console login or ssh session with X11 forwarding disabled.

Steps to Reproduce:
1. Create or obtain a PGP-encrypted file, encrypted with a public key for
   which you have the private key (on your GPG secret keyring).

   For example:
   $ ls -l | gpg2 --encrypt -a >pinentry.test.asc

   (Select an appropriate public key when prompted.)

2. From an Xterminal shell, decrypt the file:

   $ echo $DISPLAY
   $ gpg2 --decrypt <pinentry.test.asc

3. Either wait until the cache has timed out (default 10 minutes) or kill
   the gpg-agent.

4. From a console terminal (e.g., press Ctrl+Alt+F3, or so), decrypt the file:

   $ echo $DISPLAY

   $ gpg2 --decrypt <pinentry.test.asc

   Anything you type at this point will appear on the screen, but it is not
   taken as input by the pinentry program.

5. Run 'top -i'

Actual results:

top - 17:48:31 up  1:44,  4 users,  load average: 0.90, 0.33, 0.16
Tasks: 178 total,   2 running, 176 sleeping,   0 stopped,   0 zombie
Cpu(s): 19.2%us,  5.9%sy,  0.0%ni, 74.8%id,  0.0%wa,  0.2%hi,  0.0%si,  0.0%st
Mem:   4015444k total,  1553796k used,  2461648k free,    58964k buffers
Swap:  4194300k total,        0k used,  4194300k free,   707244k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
 2763 crh       20   0  100m 2724 2208 R 99.4  0.1   1:47.22 pinentry-gtk-2     
 2765 crh       20   0 15260 1268  908 R  0.0  0.0   0:00.03 top                

When run from a console terminal (with no cached passphrase), the pinentry-gtk-2 program does not fall back to pinentry-curses as it should.
It consumes CPU resources until killed with -KILL.

Expected results:

1) The pinentry-gtk-2 module should fall back to pinentry-curses if there is
   no $DISPLAY value.

2) If gpg2 is run from a terminal window (Xterminal, ssh, or otherwise), the
   pinentry-curses module should be used to accept input whether $DISPLAY is
   defined or not.  All other input to the program is via the text terminal.
   The passphrase input should not be an exception.

3) The gpg2 and gpg-agent documentation included with the XFCE Spin
   installation provides a great deal of information about default
   configuration file names and locations, as well as script file
   pathnames, and such-like.  XFCE does things differently, and finding
   the information is difficult making debugging harder and all attempts
   to fix the problem by hand more difficult.

Additional info:

gpg-agent is started by /etc/xdg/xfce4/xinitrc at X login or, if the user logs in at a console (e.g. tty3) and no gpg-agent is running, gpg-agent will be started by gpg2.  The only difference between the two is the location of the listening socket and whether or not a gpg-agent-info file is written in $HOME/.cache/.  Testing shows no behavioural difference.

Removal of the package pinentry-gtk-0.8.1-4.fc16 results in the following error messages from gpg2:

gpg: problem with the agent: No pinentry
gpg: public key decryption failed: Operation cancelled
gpg: decryption failed: No secret key

...indicating that gpg-agent (or possibly the /usr/bin/pinentry script) truly has no clue how to fall back to pinentry-ncurses.
Comment 1 Christopher R. Hertel 2012-03-20 19:44:44 EDT
I wrote above:

  "If an X display is available via ssh port forwarding, pinentry-gtk-2 fails to
use the forwarded display."

This is true, but it's a tangential problem that only occurs if ssh is tunnelled over a vpn connection.  I have yet reliably reproduce it.  (It's some sort of X security problem.)

This problem would be bypassed if gpg2 run from a terminal used pinentry-curses by default (whether $DISPLAY was defined or not).
Comment 2 Stanislav Ochotnicky 2012-06-11 09:43:47 EDT
There are at least 2 bugs here. 

First problem is more or less that when you run pinentry within gnupg context, it has no way to know if it's running on terminal or not. That is because gnupg is running pinentry in a pipe and then forwarding output onto terminal (if it has one). So the test we added for pinentry running on terminal to fallback to curses is not evaluated as true. We can do a hard fallback to pinentry-curses for cases where all else fails I guess.

I was also able to reproduce second issue of pinentry getting stuck in a loop inside xfce environment. Here I have no idea yet why that happens. It happens for pinentry-curses under some conditions as well.
Comment 3 Christopher R. Hertel 2012-06-11 13:21:30 EDT
Regarding the first of the isolated issues:

The problem is with gnupg2, not with gnupg.  I removed gpg2 from my system and installed gpg instead, and have had no further problems.

I would suggest that this is a design flaw.  It seems wrong to me that a terminal application would call an external utility to open a gui window just to retrieve one piece of input, particularly when the external utility may or may not have an environment in which to operate.  If I am working in a terminal window--even if I do have an X environment running--I don't want a new window to pop up.  It's disruptive.

Thanks for picking these up.
Comment 4 Fedora End Of Life 2013-01-16 16:51:50 EST
This message is a reminder that Fedora 16 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 16. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '16'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 16's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 16 is end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" and open it against that version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
Comment 5 Fedora End Of Life 2013-02-13 19:30:10 EST
Fedora 16 changed to end-of-life (EOL) status on 2013-02-12. Fedora 16 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

Note You need to log in before you can comment on or make changes to this bug.