Page MenuHome GnuPG

agent_send_all_options() sets wrong ttyname on input from STDIN
Closed, ResolvedPublic

Description

This has been reported as Debian bug #359758 and it seems to be related to #187 too.

If the agent is used and input (to sign) is given via STDIN (e.g.):

echo foo | gpg --use-agent -a -b - > foo.asc
...
gpg-agent[XXX] DBG: <- OPTION ttyname=/dev/tty
...
gpg-agent[XXX]: command get_passphrase failed: Operation cancelled
gpg-agent[XXX.X] DBG: -> ERR 83886179 Operation cancelled <Pinentry>
gpg: cancelled by user
[GNUPG:] MISSING_PASSPHRASE
...

then ttyname is always /dev/tty and this (might) fails. In this case ttyname
always has to be corrected via GPG_TTY. But:

gpg --use-agent -a -b foo
...
gpg-agent[XXX] DBG: <- OPTION ttyname=/dev/pts/X
...

works as expected. In agent_send_all_options() you first try ttyname(0) and then
use tty_get_ttyname(). Maybe you need another special case for input via STDIN:
ttyname(fileno(stdin)) to fix this(?).

Details

External Link
http://bugs.debian.org/359758
Version
1.4.9

Event Timeline

dleidert set Version to 1.4.9.
dleidert set External Link to http://bugs.debian.org/359758.
dleidert added a subscriber: dleidert.
werner added a subscriber: werner.

It is basically the same code as used in gpg2. On a GNU system tty_get_ttyname
always returns "/dev/tty". This is used as a fallback solution so that we can
tell gpg-agent at least one tty which may work.

It is in general very hard to figure out the actual tty in a OS portable manner
and thus we resort to the envvar GPG_TTY as the only working solution.

I don't call this a bug but improper use; see the gpg-agent manual for details.

werner claimed this task.