Merge pull request #300 from Oisann/oisann/macos-ssh-agent-pinentry-fix

Fix: Use pinentry-mac as pinentry binary on macOS for approvals
This commit is contained in:
Bernd Schoolmann 2024-10-30 23:23:44 +01:00 committed by GitHub
commit b62ffb2cb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 2 deletions

View File

@ -9,11 +9,16 @@ import (
"github.com/twpayne/go-pinentry" "github.com/twpayne/go-pinentry"
) )
func getPassword(title string, description string) (string, error) { func getBinaryClientOption() (clientOption pinentry.ClientOption) {
binaryClientOption := pinentry.WithBinaryNameFromGnuPGAgentConf() binaryClientOption := pinentry.WithBinaryNameFromGnuPGAgentConf()
if runtime.GOOS == "darwin" { if runtime.GOOS == "darwin" {
binaryClientOption = pinentry.WithBinaryName("pinentry-mac") binaryClientOption = pinentry.WithBinaryName("pinentry-mac")
} }
return binaryClientOption
}
func getPassword(title string, description string) (string, error) {
binaryClientOption := getBinaryClientOption()
client, err := pinentry.NewClient( client, err := pinentry.NewClient(
binaryClientOption, binaryClientOption,
@ -49,8 +54,10 @@ func getApproval(title string, description string) (bool, error) {
return true, nil return true, nil
} }
binaryClientOption := getBinaryClientOption()
client, err := pinentry.NewClient( client, err := pinentry.NewClient(
pinentry.WithBinaryNameFromGnuPGAgentConf(), binaryClientOption,
pinentry.WithGPGTTY(), pinentry.WithGPGTTY(),
pinentry.WithTitle(title), pinentry.WithTitle(title),
pinentry.WithDesc(description), pinentry.WithDesc(description),