diablodale / pinentry-wsl-ps1

GUI for GPG within Windows WSL for passwords, pinentry, etc.
Mozilla Public License 2.0
98 stars 9 forks source link

Modify instructions to use update-alternatives #15

Open andsens opened 2 years ago

andsens commented 2 years ago

In cases where dotfiles are synchronized across machines (and gpg-agent.conf is tracked), modifying the agent options is cumbersome or maybe not even feasible.
There is a much more machine specific and robust way of changing pinentry though: update-alternatives.
The GnuPG install on Debian based distros uses this anyways (not sure about others though). So it's just a matter of updating the pinentry program we want to use through that.

diablodale commented 2 years ago

I like this doc idea. A few inquires...

My U18.04 and U20.04 already have pinentry as an alt and it points to /usr/bin/pinentry-curses with priority 50. I think it wise to caution users that if this alt method is used, then any program that uses pinentry will now use this script yet it hasn't been designed or tested outside gpg use.

I lean towards putting this at the 3rd of 3 options as "2.iii" so that the first two options isolate the pinentry change to only gpg so to prevent conflicts.

I don't think we can guarantee that the pinentry master link is at `/usr/bin/pinentry'. A distro or admin might have it elsewhere. This causes the master symlink to be moved which may cause problems.

dale@dale-xmg$ sudo update-alternatives --install /usr/bin/pinentry5 pinentry5 /mnt/c/njs/pinentry-wsl-ps1/pinentry-wsl-ps1.sh 50

update-alternatives: using /mnt/c/njs/pinentry-wsl-ps1/pinentry-wsl-ps1.sh to provide /usr/bin/pinentry5 (pinentry5) in auto mode

dale@dale-xmg$ sudo update-alternatives --install /usr/local/bin/pinentry5 pinentry5 /mnt/c/njs/pinentry-wsl-ps1/loop.bat 50

update-alternatives: renaming pinentry5 link from /usr/bin/pinentry5 to /usr/local/bin/pinentry5`

In the above 2nd command, two things occurred. A 2nd alternative was added and the master symlink was moved from /usr/etc to /usr/local/etc. Looking at your PR, if the master link isn't /usr/etc/pinentry then your suggestion will move the link...which may cause issues.

andsens commented 2 years ago

All good, points. Though I have yet to see anything except gpg use pinentry, but that's beside the point.

I don't think we can guarantee that the pinentry master link is at `/usr/bin/pinentry'

I think we can, I'll have to do some research, but I think it's part of all the debian package install scripts for pinentry. I'll take a look through them and maybe even find a better way of doing this generically.