aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2021-04-01 08:34:06 +0000
committerWerner Koch <[email protected]>2021-04-01 08:34:06 +0000
commitc727951a2440913bbab5b250c9bd2bb1d35ab0d7 (patch)
treefb90571a1ac0749129287fd21955251d2ed8d360 /tools
parentscd: New flag --reread for LEARN (diff)
downloadgnupg-c727951a2440913bbab5b250c9bd2bb1d35ab0d7.tar.gz
gnupg-c727951a2440913bbab5b250c9bd2bb1d35ab0d7.zip
card: New flag --reread for LIST.
* tools/gpg-card.c (cmd_list): Add flag --reread. * tools/card-call-scd.c (scd_learn): New arg reread. * tools/card-call-scd.c (release_card_info): Fix releasing of the new label var. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tools')
-rw-r--r--tools/card-call-scd.c8
-rw-r--r--tools/gpg-card.c17
-rw-r--r--tools/gpg-card.h2
3 files changed, 16 insertions, 11 deletions
diff --git a/tools/card-call-scd.c b/tools/card-call-scd.c
index 5a2b3001d..086503b1c 100644
--- a/tools/card-call-scd.c
+++ b/tools/card-call-scd.c
@@ -157,7 +157,7 @@ release_card_info (card_info_t info)
while (info->kinfo)
{
key_info_t kinfo = info->kinfo->next;
- xfree (kinfo->label);
+ xfree (info->kinfo->label);
xfree (info->kinfo);
info->kinfo = kinfo;
}
@@ -1151,7 +1151,7 @@ learn_status_cb (void *opaque, const char *line)
/* Call the scdaemon to learn about a smartcard. This fills INFO
* with data from the card. */
gpg_error_t
-scd_learn (card_info_t info)
+scd_learn (card_info_t info, int reread)
{
gpg_error_t err;
struct default_inq_parm_s parm;
@@ -1168,7 +1168,9 @@ scd_learn (card_info_t info)
return err;
parm.ctx = agent_ctx;
- err = assuan_transact (agent_ctx, "SCD LEARN --force",
+ err = assuan_transact (agent_ctx,
+ reread? "SCD LEARN --force --reread"
+ /* */: "SCD LEARN --force",
dummy_data_cb, NULL, default_inq_cb, &parm,
learn_status_cb, info);
/* Also try to get some other key attributes. */
diff --git a/tools/gpg-card.c b/tools/gpg-card.c
index fa6d62325..d9d626c5f 100644
--- a/tools/gpg-card.c
+++ b/tools/gpg-card.c
@@ -1129,7 +1129,7 @@ static gpg_error_t
cmd_list (card_info_t info, char *argstr)
{
gpg_error_t err;
- int opt_cards, opt_apps, opt_info, opt_no_key_lookup;
+ int opt_cards, opt_apps, opt_info, opt_reread, opt_no_key_lookup;
strlist_t cards = NULL;
strlist_t sl;
estream_t fp = opt.interactive? NULL : es_stdout;
@@ -1140,7 +1140,8 @@ cmd_list (card_info_t info, char *argstr)
if (!info)
return print_help
- ("LIST [--cards] [--apps] [--info] [--no-key-lookup] [N] [APP]\n\n"
+ ("LIST [--cards] [--apps] [--info] [--reread]"
+ " [--no-key-lookup] [N] [APP]\n\n"
"Show the content of the current card.\n"
"With N given select and list the N-th card;\n"
"with APP also given select that application.\n"
@@ -1149,12 +1150,14 @@ cmd_list (card_info_t info, char *argstr)
" --cards lists available cards\n"
" --apps lists additional card applications\n"
" --info selects a card and prints its s/n\n"
+ " --reread read infos from PCKS#15 cards again\n"
" --no-key-lookup does not list matching OpenPGP or X.509 keys\n"
, 0);
opt_cards = has_leading_option (argstr, "--cards");
opt_apps = has_leading_option (argstr, "--apps");
opt_info = has_leading_option (argstr, "--info");
+ opt_reread = has_leading_option (argstr, "--reread");
opt_no_key_lookup = has_leading_option (argstr, "--no-key-lookup");
argstr = skip_options (argstr);
@@ -1284,7 +1287,7 @@ cmd_list (card_info_t info, char *argstr)
}
if (need_learn)
- err = scd_learn (info);
+ err = scd_learn (info, opt_reread);
else
err = 0;
@@ -2669,7 +2672,7 @@ cmd_generate (card_info_t info, char *argstr)
if (!err)
{
- err = scd_learn (info);
+ err = scd_learn (info, 0);
if (err)
log_error ("Error re-reading card: %s\n", gpg_strerror (err));
}
@@ -3026,7 +3029,7 @@ cmd_factoryreset (card_info_t info)
* specific resset command.
*/
- err = scd_learn (info);
+ err = scd_learn (info, 0);
if (gpg_err_code (err) == GPG_ERR_OBJ_TERM_STATE
&& gpg_err_source (err) == GPG_ERR_SOURCE_SCD)
termstate = 1;
@@ -3482,7 +3485,7 @@ cmd_yubikey (card_info_t info, char *argstr)
/* Note that we always do a learn to get a chance to the card back
* into a usable state. */
err = yubikey_commands (info, fp, nwords, words);
- err2 = scd_learn (info);
+ err2 = scd_learn (info, 0);
if (err2)
log_error ("Error re-reading card: %s\n", gpg_strerror (err));
@@ -3718,7 +3721,7 @@ dispatch_command (card_info_t info, const char *orig_command)
|| cmd == cmdINVCMD)
&& !info->initialized)
{
- err = scd_learn (info);
+ err = scd_learn (info, 0);
if (err)
{
err = fixup_scd_errors (err);
diff --git a/tools/gpg-card.h b/tools/gpg-card.h
index b79d12d0d..0407da12e 100644
--- a/tools/gpg-card.h
+++ b/tools/gpg-card.h
@@ -227,7 +227,7 @@ gpg_error_t scd_apdu (const char *hexapdu, const char *options,
gpg_error_t scd_switchcard (const char *serialno);
gpg_error_t scd_switchapp (const char *appname);
-gpg_error_t scd_learn (card_info_t info);
+gpg_error_t scd_learn (card_info_t info, int reread);
gpg_error_t scd_getattr (const char *name, struct card_info_s *info);
gpg_error_t scd_setattr (const char *name,
const unsigned char *value, size_t valuelen);