Alright, I think I've got it.
I used the custom pinentry script mentioned here
(http://unix.stackexchange.com/questions/236746/change-pinentry-program-temporarily-with-gpg-agent)
[1] and placed it in `/usr/local/bin/pinentry-custom` and set
pinentry-program in gpg-agent.conf to that (obviously). I then created
a gpg2 wrapper script that exports PINENTRY_USERDATA=gtk [2] and
overwrote the gpg executable in enigmail with it. I had to do that
because enigmail does not forward the environment variables that
thunderbird was called with to gpg2.

[1] https://a3nm.net/git/mybin/tree/my-pinentry
#!/bin/bash
# choose pinentry depending on PINENTRY_USER_DATA
# requires pinentry-curses and pinentry-gtk2
# this *only works* with gpg 2
# see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=802020

case $PINENTRY_USER_DATA in
gtk)
  exec /usr/bin/pinentry-gtk-2 "$@"
  ;;
*)
  exec /usr/bin/pinentry-curses "$@"
esac


[2] /usr/local/bin/gpg-gtk-pinentry
#!/usr/bin/env sh
# Run gpg w/ gtk pinentry
# This only works if gpg's pinentry is set to '/usr/local/bin/pinentry-custom'

export PINENTRY_USER_DATA=gtk
exec gpg2 "$@"

Thank you very much for your help and I hope that this may be useful
to someone else in the future.

2016-09-10 13:23 GMT+02:00 Patrick Ziegler <[email protected]>:
> Indeed brilliant! Thank you very much, now let's just hope that the
> environment variables are getting passed on properly. I will try this
> out today or tomorrow hopefully and will of course tell you if and how
> it worked.
>
> 2016-09-10 12:00 GMT+02:00 Ludwig Hügelschäfer <[email protected]>:
>> On 10.09.16 09:44, Patrick Brunschwig wrote:
>>>
>>> I see a way how this could possibly be achieved, even though it may
>>> be a little complicated.
>>>
>>> You could create a wrapper script that determines based on some
>>> logic (e.g. some environment variable) whether to open a graphical
>>> pinentry or pinentry-curses. The wrapper script would be configured
>>> in gpg-agent.conf as "pinentry-program". Key point: the wrapper
>>> script would need to exec the chosen pinentry programm (i.e. the real
>>> pinentry replaces the wrapper).
>>
>> Brilliant idea, Patrick! Patrick Ziegler, please forget my overly
>> pessimistic response :-)
>>
>> Ludwig
>>
>>
>>
>> _______________________________________________
>> enigmail-users mailing list
>> [email protected]
>> To unsubscribe or make changes to your subscription click here:
>> https://admin.hostpoint.ch/mailman/listinfo/enigmail-users_enigmail.net
>>

_______________________________________________
enigmail-users mailing list
[email protected]
To unsubscribe or make changes to your subscription click here:
https://admin.hostpoint.ch/mailman/listinfo/enigmail-users_enigmail.net

Reply via email to