mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-08 12:44:23 +01:00
gpg: Change API of agent_scd_serialno.
* g10/call-agent.c (agent_scd_serialno): Extend API to allow with R_SERIALNO == NULL. * g10/card-util.c (card_status): Use NULL for agent_scd_serialno. (factory_reset): Likewise. * g10/skclist.c (build_sk_list): Likewise. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
cc8b99d18e
commit
777019faf0
@ -1408,7 +1408,9 @@ agent_scd_serialno (char **r_serialno, const char *demand)
|
||||
char *serialno = NULL;
|
||||
char line[ASSUAN_LINELENGTH];
|
||||
|
||||
*r_serialno = NULL;
|
||||
if (r_serialno)
|
||||
*r_serialno = NULL;
|
||||
|
||||
err = start_agent (NULL, (1 | FLAG_FOR_CARD_SUPPRESS_ERRORS));
|
||||
if (err)
|
||||
return err;
|
||||
@ -1427,7 +1429,11 @@ agent_scd_serialno (char **r_serialno, const char *demand)
|
||||
return err;
|
||||
}
|
||||
|
||||
*r_serialno = serialno;
|
||||
if (r_serialno)
|
||||
*r_serialno = serialno;
|
||||
else
|
||||
xfree (serialno);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -689,7 +689,6 @@ card_status (ctrl_t ctrl, estream_t fp, const char *serialno)
|
||||
int err;
|
||||
strlist_t card_list, sl;
|
||||
char *serialno0 = NULL;
|
||||
char *serialno1 = NULL;
|
||||
int all_cards = 0;
|
||||
int any_card = 0;
|
||||
|
||||
@ -723,7 +722,7 @@ card_status (ctrl_t ctrl, estream_t fp, const char *serialno)
|
||||
tty_fprintf (fp, "\n");
|
||||
any_card = 1;
|
||||
|
||||
err = agent_scd_serialno (&serialno1, sl->d);
|
||||
err = agent_scd_serialno (NULL, sl->d);
|
||||
if (err)
|
||||
{
|
||||
if (opt.verbose)
|
||||
@ -733,19 +732,16 @@ card_status (ctrl_t ctrl, estream_t fp, const char *serialno)
|
||||
}
|
||||
|
||||
current_card_status (ctrl, fp, NULL, 0);
|
||||
xfree (serialno1);
|
||||
serialno1 = NULL;
|
||||
|
||||
if (!all_cards)
|
||||
goto leave;
|
||||
}
|
||||
|
||||
/* Select the original card again. */
|
||||
err = agent_scd_serialno (&serialno1, serialno0);
|
||||
err = agent_scd_serialno (NULL, serialno0);
|
||||
|
||||
leave:
|
||||
xfree (serialno0);
|
||||
xfree (serialno1);
|
||||
free_strlist (card_list);
|
||||
}
|
||||
|
||||
@ -2010,12 +2006,7 @@ factory_reset (void)
|
||||
|
||||
/* Then, connect the card again. */
|
||||
if (!err)
|
||||
{
|
||||
char *serialno0;
|
||||
|
||||
err = agent_scd_serialno (&serialno0, NULL);
|
||||
xfree (serialno0);
|
||||
}
|
||||
err = agent_scd_serialno (NULL, NULL);
|
||||
|
||||
leave:
|
||||
if (locked)
|
||||
|
@ -131,17 +131,15 @@ build_sk_list (ctrl_t ctrl,
|
||||
{
|
||||
struct agent_card_info_s info;
|
||||
PKT_public_key *pk;
|
||||
char *serialno;
|
||||
|
||||
memset (&info, 0, sizeof(info));
|
||||
pk = xmalloc_clear (sizeof *pk);
|
||||
pk->req_usage = use;
|
||||
|
||||
/* Check if a card is available. If any, use the key as a hint. */
|
||||
err = agent_scd_serialno (&serialno, NULL);
|
||||
err = agent_scd_serialno (NULL, NULL);
|
||||
if (!err)
|
||||
{
|
||||
xfree (serialno);
|
||||
err = agent_scd_getattr ("KEY-FPR", &info);
|
||||
if (err)
|
||||
log_error ("error retrieving key fingerprint from card: %s\n",
|
||||
@ -382,8 +380,6 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
|
||||
/* Loop over the list of secret keys. */
|
||||
do
|
||||
{
|
||||
char *serialno;
|
||||
|
||||
name = NULL;
|
||||
keyblock = NULL;
|
||||
switch (c->state)
|
||||
@ -410,10 +406,9 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
|
||||
|
||||
case 3: /* Init list of card keys to try. */
|
||||
c->card_keyinfo_list = NULL;
|
||||
err = agent_scd_serialno (&serialno, NULL);
|
||||
err = agent_scd_serialno (NULL, NULL);
|
||||
if (!err)
|
||||
{
|
||||
xfree (serialno);
|
||||
err = agent_scd_keyinfo (NULL, GCRY_PK_USAGE_ENCR,
|
||||
&c->card_keyinfo_list);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user