threads / discuss / 60942

Calling "gpg --sign" with loopback pinentry in some scenarios, but not always

Subject: Calling "gpg --sign" with loopback pinentry in some scenarios, but not always

## tl;dr

2 messages between Feb 17, 2024 and Feb 17, 2024.

replies: 1people: 2as markdown or json

Jens Schmidt· Feb 17, 2024, 22:51 UTC · lore
Hi.

I'd like to use gpg loopback pinentry mode when signing commits or tags through Emacs/Magit but default, non-loopback pinentry for all other cases.

In particular, configuring "pinentry-mode loopback" in "gpg.conf" is not really an option for me.

It seems that "git" does not have any hooks to pass arbitrary additional parameters to "gpg", right? So my only reasonable option would be a Emacs/Magit-specific "gpg"-wrapper that adds command line parameter "--pinentry-mode loopback" to the wrapped "gpg" executable.

Any other options?
Thanks!
Junio C Hamano· Feb 17, 2024, 23:31 UTC · re: Jens Schmidt · lore

Re: Calling "gpg --sign" with loopback pinentry in some scenarios, but not always

Jens Schmidt <farblos@vodafonemail.de> writes:
Show 5 quoted lines
> It seems that "git" does not have any hooks to pass arbitrary
> additional parameters to "gpg", right?  So my only reasonable
> option would be a Emacs/Magit-specific "gpg"-wrapper that adds
> command line parameter "--pinentry-mode loopback" to the wrapped
> "gpg" executable.

Correct. You can point your gpg.program configuration variable at your wrapper, perhaps

    $ cat >"$HOME/bin/mygpg-with-pinentry" <<\EOF
    #!/bin/sh
    exec gpg --pinentry-mode loopback "$@"
    EOF
    $ chmod +x "$HOME/bin/mygpg-with-pinentry"
    $ git config gpg.openpgp.program "$HOME/bin/mygpg-with-pinentry"
or something like that.  It is unfortunate that
    $ git config gpg.openpgp.program "gpg --pinentry-mode loopback"
does not work.

← back to recent threads