From 13c651c21f768fcb243adff2a24e2259057e9748 Mon Sep 17 00:00:00 2001 From: "florian on nixos (Florian Brandes)" Date: Wed, 10 Nov 2021 18:40:59 +0100 Subject: [PATCH 1/4] partly fixes #1. Check path of pinentry. Up until now pinentry_others returned the path of pinentry as it is returned by gpgconf. Unfortunately this is hard-coded and sometimes not correct. This commit adds a check for the path and falls back to the old behviour (return pinentry from PATH). Signed-off-by: florian on nixos (Florian Brandes) --- pinentry_others.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pinentry_others.go b/pinentry_others.go index 4a60e38..a0380f8 100644 --- a/pinentry_others.go +++ b/pinentry_others.go @@ -2,12 +2,18 @@ package pinentry -import "github.com/gopasspw/pinentry/gpgconf" +import ( + "github.com/gopasspw/pinentry/gpgconf" + "os/exec" +) // GetBinary returns the binary name func GetBinary() string { if p, err := gpgconf.Path("pinentry"); err == nil && p != "" { - return p + // check, whether the returned path acutally exists + if _, err := exec.LookPath(p); err == nil { + return p + } } return "pinentry" } From 746a7e53ec91613a89961490f2178c664a2b05c0 Mon Sep 17 00:00:00 2001 From: "florian on nixos (Florian Brandes)" Date: Thu, 11 Nov 2021 06:53:53 +0100 Subject: [PATCH 2/4] change module github url Signed-off-by: florian on nixos (Florian Brandes) --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 4ef731d..bb3b967 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/gopasspw/pinentry +module github.com/gador/pinentry go 1.16 From f49735e1731aeef4b839100f361fef5e69a29446 Mon Sep 17 00:00:00 2001 From: "florian on nixos (Florian Brandes)" Date: Thu, 11 Nov 2021 07:01:51 +0100 Subject: [PATCH 3/4] Revert "change module github url" This reverts commit b226db3124bd8532e495f5f9a718201a8f0bc0a3. Signed-off-by: florian on nixos (Florian Brandes) --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index bb3b967..4ef731d 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/gador/pinentry +module github.com/gopasspw/pinentry go 1.16 From 6c52bbc4c84b289613db3751be9b2ae3d5d9457b Mon Sep 17 00:00:00 2001 From: Dominik Schulz Date: Sat, 18 Dec 2021 21:52:35 +0100 Subject: [PATCH 4/4] Prefer pinentry-mac on Darwin gpgconf isn't very reliable or useful. --- pinentry_darwin.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pinentry_darwin.go b/pinentry_darwin.go index f634a1e..40c0c86 100644 --- a/pinentry_darwin.go +++ b/pinentry_darwin.go @@ -1,11 +1,20 @@ +//go:build darwin // +build darwin package pinentry -import "github.com/gopasspw/pinentry/gpgconf" +import ( + "os/exec" + + "github.com/gopasspw/pinentry/gpgconf" +) // GetBinary always returns pinentry-mac func GetBinary() string { + // check, whether the returned path acutally exists + if _, err := exec.LookPath("pinentry-mac"); err == nil { + return "pinentry-mac" + } if p, err := gpgconf.Path("pinentry"); err == nil && p != "" { return p }