mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-23 15:07:03 +01:00
g10: Support specifying SERIALNO for --card-status.
* g10/gpg.c (main): Allow an argument for --card-status. * g10/card-util.c (current_card_status): Rename from card_status. (card_status): New, which supports multiple cards. (get_one_name): Use current_card_status. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
d58275703f
commit
c1e6302b34
@ -361,8 +361,8 @@ fpr_is_ff (const char *fpr)
|
|||||||
|
|
||||||
|
|
||||||
/* Print all available information about the current card. */
|
/* Print all available information about the current card. */
|
||||||
void
|
static void
|
||||||
card_status (estream_t fp, char *serialno, size_t serialnobuflen)
|
current_card_status (estream_t fp, char *serialno, size_t serialnobuflen)
|
||||||
{
|
{
|
||||||
struct agent_card_info_s info;
|
struct agent_card_info_s info;
|
||||||
PKT_public_key *pk = xcalloc (1, sizeof *pk);
|
PKT_public_key *pk = xcalloc (1, sizeof *pk);
|
||||||
@ -625,6 +625,70 @@ card_status (estream_t fp, char *serialno, size_t serialnobuflen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Print all available information for specific card with SERIALNO.
|
||||||
|
Print all available information for current card when SERIALNO is NULL.
|
||||||
|
Or print llfor all cards when SERIALNO is "all". */
|
||||||
|
void
|
||||||
|
card_status (estream_t fp, const char *serialno)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
strlist_t card_list, sl;
|
||||||
|
char *serialno0;
|
||||||
|
int all_cards = 0;
|
||||||
|
|
||||||
|
if (serialno == NULL)
|
||||||
|
{
|
||||||
|
current_card_status (fp, NULL, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp (serialno, "all"))
|
||||||
|
all_cards = 1;
|
||||||
|
|
||||||
|
err = agent_scd_serialno (&serialno0, NULL);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
if (gpg_err_code (err) != GPG_ERR_ENODEV && opt.verbose)
|
||||||
|
log_info (_("error getting serial number of card: %s\n"),
|
||||||
|
gpg_strerror (err));
|
||||||
|
/* Nothing available. */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = agent_scd_cardlist (&card_list);
|
||||||
|
|
||||||
|
for (sl = card_list; sl; sl = sl->next)
|
||||||
|
{
|
||||||
|
char *serialno1;
|
||||||
|
|
||||||
|
if (!all_cards && strcmp (serialno, sl->d))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
err = agent_scd_serialno (&serialno1, sl->d);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
if (opt.verbose)
|
||||||
|
log_info (_("error getting serial number of card: %s\n"),
|
||||||
|
gpg_strerror (err));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_card_status (fp, NULL, 0);
|
||||||
|
xfree (serialno1);
|
||||||
|
|
||||||
|
if (!all_cards)
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Select the original card again. */
|
||||||
|
err = agent_scd_serialno (&serialno0, serialno0);
|
||||||
|
|
||||||
|
leave:
|
||||||
|
xfree (serialno0);
|
||||||
|
free_strlist (card_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_one_name (const char *prompt1, const char *prompt2)
|
get_one_name (const char *prompt1, const char *prompt2)
|
||||||
{
|
{
|
||||||
@ -1919,16 +1983,16 @@ card_edit (ctrl_t ctrl, strlist_t commands)
|
|||||||
int cmd_admin_only;
|
int cmd_admin_only;
|
||||||
|
|
||||||
tty_printf("\n");
|
tty_printf("\n");
|
||||||
if (redisplay )
|
if (redisplay)
|
||||||
{
|
{
|
||||||
if (opt.with_colons)
|
if (opt.with_colons)
|
||||||
{
|
{
|
||||||
card_status (es_stdout, serialnobuf, DIM (serialnobuf));
|
current_card_status (es_stdout, serialnobuf, DIM (serialnobuf));
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
card_status (NULL, serialnobuf, DIM (serialnobuf));
|
current_card_status (NULL, serialnobuf, DIM (serialnobuf));
|
||||||
tty_printf("\n");
|
tty_printf("\n");
|
||||||
}
|
}
|
||||||
redisplay = 0;
|
redisplay = 0;
|
||||||
|
@ -4791,9 +4791,12 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
#ifdef ENABLE_CARD_SUPPORT
|
#ifdef ENABLE_CARD_SUPPORT
|
||||||
case aCardStatus:
|
case aCardStatus:
|
||||||
if (argc)
|
if (argc == 0)
|
||||||
wrong_args ("--card-status");
|
card_status (es_stdout, NULL);
|
||||||
card_status (es_stdout, NULL, 0);
|
else if (argc == 1)
|
||||||
|
card_status (es_stdout, *argv);
|
||||||
|
else
|
||||||
|
wrong_args ("--card-status [serialno]");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case aCardEdit:
|
case aCardEdit:
|
||||||
|
@ -485,7 +485,7 @@ gpg_error_t gpg_proxy_pinentry_notify (ctrl_t ctrl,
|
|||||||
#ifdef ENABLE_CARD_SUPPORT
|
#ifdef ENABLE_CARD_SUPPORT
|
||||||
/*-- card-util.c --*/
|
/*-- card-util.c --*/
|
||||||
void change_pin (int no, int allow_admin);
|
void change_pin (int no, int allow_admin);
|
||||||
void card_status (estream_t fp, char *serialno, size_t serialnobuflen);
|
void card_status (estream_t fp, const char *serialno);
|
||||||
void card_edit (ctrl_t ctrl, strlist_t commands);
|
void card_edit (ctrl_t ctrl, strlist_t commands);
|
||||||
gpg_error_t card_generate_subkey (KBNODE pub_keyblock);
|
gpg_error_t card_generate_subkey (KBNODE pub_keyblock);
|
||||||
int card_store_subkey (KBNODE node, int use);
|
int card_store_subkey (KBNODE node, int use);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user