"gpg: deleting secret key failed: No pinentry" when in --batch mode with --pinentry=loopback
Open, NormalPublic


when doing --delete-secret-key with --batch --pinentry-mode=loopback --passphrase '' (a common set of parameters for headless test suites, etc), i get these error messages:

gpg: deleting secret key failed: No pinentry
gpg: 0xC66EE6825C56BD2DD7D5249BCD06DA2AF8754C37!: delete key failed: No pinentry

The manual page gives a hint that --yes is required in this case, though --yes also has other side effects that might or might not be desirable. Perhaps --pinentry-mode=loopback should be interpreted in the same way as --yes in this context?

or at least, the error message should be more along the lines of "i'm in batch mode, and i need to prompt, perhaps you mean --yes?"

Here is a reproducer:

and here is sample output:

++ mktemp -d
+ homedir=/home/dkg/tmp/tmp.4sY3eX3qaK
+ trap cleanup exit
+ opts=(--homedir "$homedir" --pinentry-mode loopback --passphrase '' --batch)
+ g --quick-gen-key 'test user <test@example.org>' default default 0
+ gpg --homedir /home/dkg/tmp/tmp.4sY3eX3qaK --pinentry-mode loopback --passphrase '' --batch --quick-gen-key 'test user <test@example.org>' default default 0
gpg: keybox '/home/dkg/tmp/tmp.4sY3eX3qaK/pubring.kbx' created
gpg: /home/dkg/tmp/tmp.4sY3eX3qaK/trustdb.gpg: trustdb created
gpg: key 778F4460EEDF95A1 marked as ultimately trusted
gpg: directory '/home/dkg/tmp/tmp.4sY3eX3qaK/openpgp-revocs.d' created
gpg: revocation certificate stored as '/home/dkg/tmp/tmp.4sY3eX3qaK/openpgp-revocs.d/1DB023A18E1573B941CF7754778F4460EEDF95A1.rev'
++ g --list-keys --with-colons
++ gpg --homedir /home/dkg/tmp/tmp.4sY3eX3qaK --pinentry-mode loopback --passphrase '' --batch --list-keys --with-colons
++ get_primary_fpr
++ awk -F: '/^pub:/{ x = 1 } /^sub:/{ x = 0 } /^fpr:/{ if (x) { print $10 } }'
gpg: checking the trustdb
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
+ fpr=1DB023A18E1573B941CF7754778F4460EEDF95A1
+ g --delete-secret-key '0x1DB023A18E1573B941CF7754778F4460EEDF95A1!'
+ gpg --homedir /home/dkg/tmp/tmp.4sY3eX3qaK --pinentry-mode loopback --passphrase '' --batch --delete-secret-key '0x1DB023A18E1573B941CF7754778F4460EEDF95A1!'
gpg: deleting secret key failed: No pinentry
gpg: 0x1DB023A18E1573B941CF7754778F4460EEDF95A1!: delete key failed: No pinentry
+ cleanup
+ printf 'cleaning up ephemeral homedir %s\n' /home/dkg/tmp/tmp.4sY3eX3qaK
cleaning up ephemeral homedir /home/dkg/tmp/tmp.4sY3eX3qaK
+ rm -rf /home/dkg/tmp/tmp.4sY3eX3qaK


dkg created this task.Aug 3 2019, 7:15 PM
werner triaged this task as Normal priority.Aug 5 2019, 7:51 PM