Home GnuPG

curses: Do not return OK on error.
ce745a292192Unpublished

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

curses: Do not return OK on error.

* pinentry/pinentry.c (cmd_confirm): Take care not to return OK if the
RESULT is negative.
* pinentry/pinentry-curses.c (dialog_create): Amend error reporting by
setting specific_err_loc.
(dialog_run): Use new var confirm_mode for clearness.  In confirm mode
return Cancel instead of error.  This is how the gtk Pinentry does it.

A common error case is that a tty is not available and thus the fopen
fails. In this case it is plainly wrong to return OK, we would better
return CANCEL. Even better the specicic_err thing is now used to
return a proper error code. For example:

$ pinentry-curses --ttyname=/dev/no/such/tty
OK Pleased to meet you
getinfo ttyinfo
D /dev/no/such/tty - -
OK
confirm
S ERROR curses.open_tty_for_read 83918929
ERR 83918929 No such file or directory <Pinentry>

The curses pinentry is also used as fallback from gtk. Thus in this
case we now also get a error message back:

$ pinentry-gtk-2 --display=/dev/null --ttyname=/dev/no/such/tty
OK Pleased to meet you
getinfo flavor
D gtk2:curses
OK
getinfo ttyinfo
D /dev/no/such/tty - /dev/null
OK
confirm
S ERROR gtk2.open_tty_for_read 83918929
ERR 83918929 No such file or directory <Pinentry>

Returning an error instead of OK also fixes this bug: A background
task is asking to insert a certain smartcard and asks via pinentry for
it. Now w/o a valid tty the old code return OK and gpg-agent started
new pinentries (which don't show up) over and over until the correct
card was inserted.

  • Signed-off-by: Werner Koch <wk@gnupg.org>

Details

Provenance
wernerAuthored on Feb 3 2017, 11:53 AM
Parents
rPcd45d74d0751: core: New command getinfo/ttyinfo
Branches
Unknown
Tags
Unknown