GPGTools/pinentry-mac — pull request #2 by idodeclare (2012-05-24 18:59:18+00:00)
Title: Fallback curses

Hi, guys.

This is for your consideration.

I had enabled a couple months back a fallback to curses (as other
platforms do) for my private version for when I needed to decrypt on
an ssh command-line.

Like the other platform versions, it was keyed off DISPLAY,
which I think is not a good Mac solution in general since many users
do not use X11. I'm not even sure whether DISPLAY is still managed
by OS X when X11 is not available. I only have a Lion test system,
where X11 is installed as a requirement. (I wonder of Mountain Lion
where X11 is not a default: does it manage DISPLAY?).

My current thinking is that for Mac, SSH_CONNECTION is probably
a good indicator for whether to use the Aqua pinentry or to fallback
to curses.

Ideally, gpg2, gpg-agent, and pinentry would automatically coordinate
the state of this variable—as they do for DISPLAY—but that's not
the current case.

So this pinentry-mac contribution allows it to recognize USE_CURSES=1
in the environment variable PINENTRY_USER_DATA (which is currently
automatically passed from session > gpg2 > gpg-agent > pinentry)
to allow the user to specify that curses should be initialized.

I enable this in my .bashrc or .profile with the following:

if test "$SSH_CONNECTION" != ""
then
export PINENTRY_USER_DATA="USE_CURSES=1"
fi