gpg: Print all keys with --decrypt --list-only.

* g10/mainproc.c (proc_pubkey_enc): Use dedicated error code for
list-only and put the key into PKENC_LIST.
(print_pkenc_list): Take care of the new error code.
--

If the secret keys exist in --list-only mode it was not printed in
--list-only mode.

GnuPG-bug-id: 3718
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-01-08 09:30:31 +01:00
parent 4d3c500f47
commit 339b3301ee
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 6 additions and 4 deletions

View File

@ -422,7 +422,7 @@ proc_pubkey_enc (ctrl_t ctrl, CTX c, PACKET *pkt)
|| have_secret_key_with_kid (enc->keyid)))
{
if(opt.list_only)
result = -1;
result = GPG_ERR_MISSING_ACTION; /* fixme: Use better error code. */
else
{
c->dek = xmalloc_secure_clear (sizeof *c->dek);
@ -440,9 +440,7 @@ proc_pubkey_enc (ctrl_t ctrl, CTX c, PACKET *pkt)
else
result = GPG_ERR_PUBKEY_ALGO;
if (result == -1)
;
else
if (1)
{
/* Store it for later display. */
struct kidlist_item *x = xmalloc (sizeof *x);
@ -510,6 +508,10 @@ print_pkenc_list (ctrl_t ctrl, struct kidlist_item *list, int failed)
write_status_text (STATUS_NO_SECKEY, buf);
}
}
else if (gpg_err_code (list->reason) == GPG_ERR_MISSING_ACTION)
{
/* Not tested for secret key due to --list-only mode. */
}
else if (list->reason)
{
log_info (_("public key decryption failed: %s\n"),