From 949df7008ebaf3e5605580c9188f3f1209917e89 Mon Sep 17 00:00:00 2001 From: Mauro Regli Date: Fri, 18 Aug 2023 08:09:46 +0200 Subject: [PATCH] Fix: Remove Batch from API options, set to true by default, add comments Fixes: #1106 --- api/publish.go | 5 +++-- pgp/internal.go | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/publish.go b/api/publish.go index 830e22175..110dbe546 100644 --- a/api/publish.go +++ b/api/publish.go @@ -16,7 +16,6 @@ import ( // SigningOptions is a shared between publish API GPG options structure type SigningOptions struct { Skip bool - Batch bool GpgKey string Keyring string SecretKeyring string @@ -33,7 +32,9 @@ func getSigner(options *SigningOptions) (pgp.Signer, error) { signer.SetKey(options.GpgKey) signer.SetKeyRing(options.Keyring, options.SecretKeyring) signer.SetPassphrase(options.Passphrase, options.PassphraseFile) - signer.SetBatch(options.Batch) + + // If Batch is false, GPG will ask for passphrase on stdin, which would block the api process + signer.SetBatch(true) err := signer.Init() if err != nil { diff --git a/pgp/internal.go b/pgp/internal.go index c26348f17..5a087c4b3 100644 --- a/pgp/internal.go +++ b/pgp/internal.go @@ -46,7 +46,8 @@ type GoSigner struct { signerConfig *packet.Config } -// SetBatch controls whether we allowed to interact with user +// SetBatch controls whether we allowed to interact with user, for example +// for getting the passphrase from stdin. func (g *GoSigner) SetBatch(batch bool) { g.batch = batch }