mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
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 <wk@gnupg.org>
This commit is contained in:
parent
ff87f4e578
commit
c727951a24
@ -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. */
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user