From 8e3d4f5b63c15d9a121f568cc61735586f1782a0 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 26 Sep 2023 10:05:05 +0900 Subject: [PATCH] gpg: Keep the integrity of the code for KEYINFO command. * g10/call-agent.c (struct keyinfo_data_parm_s): Remove CARD_AVAILABLE field. (keyinfo_status_cb): Don't touch CARD_AVAILABLE field. (agent_probe_secret_key); Don't check CARD_AVAILABLE field. * g10/import.c (do_transfer): Check if it's card key or not. -- In 2.2 branch, gpg-agent doesn't have a capability to report if card is available or not by KEYINFO command. Thus, this clean up. GnuPG-bug-id: 3456 Signed-off-by: NIIBE Yutaka --- g10/call-agent.c | 6 ------ g10/import.c | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/g10/call-agent.c b/g10/call-agent.c index 03dc54456..3211649e1 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -1788,7 +1788,6 @@ struct keyinfo_data_parm_s int is_smartcard; int passphrase_cached; int cleartext; - int card_available; }; @@ -1818,8 +1817,6 @@ keyinfo_status_cb (void *opaque, const char *line) data->passphrase_cached = (fields[4][0] == '1'); /* 'P' for protected, 'C' for clear */ data->cleartext = (fields[5][0] == 'C'); - /* 'A' for card is available */ - data->card_available = (fields[8][0] == 'A'); } } return 0; @@ -1856,9 +1853,6 @@ agent_probe_secret_key (ctrl_t ctrl, PKT_public_key *pk) if (err) return 0; - if (keyinfo.card_available) - return 4; - if (keyinfo.passphrase_cached) return 3; diff --git a/g10/import.c b/g10/import.c index 49a363c28..f11dedc8b 100644 --- a/g10/import.c +++ b/g10/import.c @@ -2839,7 +2839,7 @@ do_transfer (ctrl_t ctrl, kbnode_t keyblock, PKT_public_key *pk, int force = 0; int already_exist = agent_probe_secret_key (ctrl, pk); - if (already_exist == 2 || already_exist == 4) + if (already_exist == 2) { if (!opt.quiet) log_info (_("key %s: card reference is overridden by key material\n"),