mirror of
git://git.gnupg.org/gnupg.git
synced 2024-11-10 21:38:50 +01:00
scd: New getinfo subcommand "dump_state".
* scd/command.c (cmd_getinfo): Add subcommand. Always init CTRL for simplicity. -- A state dump looks like app_dump_state: card=0x00007f1b38017c90 slot=1 type=yubikey refcount=1 app_dump_state: app=0x00007f1b38018100 type='openpgp' app_dump_state: app=0x00007f1b3800cb70 type='piv' app_dump_state: card=0x00007f1b38013a10 slot=0 type=gnuk refcount=0 app_dump_state: app=0x00007f1b38016fc0 type='openpgp' and can also be triggered by a SIGUSR1. This explicit command allows to dump the state also on Windows. Use for example gpg-connect-agent 'scd getinfo dump_state' /bye
This commit is contained in:
parent
658a139d68
commit
b614309876
@ -1874,11 +1874,13 @@ static const char hlp_getinfo[] =
|
|||||||
" - Return a list of active apps on all inserted cards.\n"
|
" - Return a list of active apps on all inserted cards.\n"
|
||||||
" cmd_has_option CMD OPT\n"
|
" cmd_has_option CMD OPT\n"
|
||||||
" - Returns OK if command CMD has option OPT.\n"
|
" - Returns OK if command CMD has option OPT.\n"
|
||||||
|
" dump_state - Dump internal infos to the log stream.\n"
|
||||||
" apdu_strerror NUMBER\n"
|
" apdu_strerror NUMBER\n"
|
||||||
" - Return a string for a status word.\n";
|
" - Return a string for a status word.\n";
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
cmd_getinfo (assuan_context_t ctx, char *line)
|
cmd_getinfo (assuan_context_t ctx, char *line)
|
||||||
{
|
{
|
||||||
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
@ -1898,6 +1900,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
|
|||||||
&& (line[14] == ' ' || line[14] == '\t' || !line[14]))
|
&& (line[14] == ' ' || line[14] == '\t' || !line[14]))
|
||||||
{
|
{
|
||||||
char *cmd, *cmdopt;
|
char *cmd, *cmdopt;
|
||||||
|
|
||||||
line += 14;
|
line += 14;
|
||||||
while (*line == ' ' || *line == '\t')
|
while (*line == ' ' || *line == '\t')
|
||||||
line++;
|
line++;
|
||||||
@ -1943,7 +1946,6 @@ cmd_getinfo (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
else if (!strcmp (line, "status"))
|
else if (!strcmp (line, "status"))
|
||||||
{
|
{
|
||||||
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
||||||
char flag;
|
char flag;
|
||||||
|
|
||||||
if (open_card (ctrl))
|
if (open_card (ctrl))
|
||||||
@ -1980,13 +1982,11 @@ cmd_getinfo (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
else if (!strcmp (line, "card_list"))
|
else if (!strcmp (line, "card_list"))
|
||||||
{
|
{
|
||||||
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
||||||
|
|
||||||
rc = app_send_card_list (ctrl);
|
rc = app_send_card_list (ctrl);
|
||||||
}
|
}
|
||||||
else if (!strcmp (line, "active_apps"))
|
else if (!strcmp (line, "active_apps"))
|
||||||
{
|
{
|
||||||
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
||||||
card_t card = card_get (ctrl, NULL);
|
card_t card = card_get (ctrl, NULL);
|
||||||
|
|
||||||
if (!card)
|
if (!card)
|
||||||
@ -1999,7 +1999,6 @@ cmd_getinfo (assuan_context_t ctx, char *line)
|
|||||||
}
|
}
|
||||||
else if (!strcmp (line, "all_active_apps"))
|
else if (!strcmp (line, "all_active_apps"))
|
||||||
{
|
{
|
||||||
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
||||||
rc = app_send_active_apps (NULL, ctrl);
|
rc = app_send_active_apps (NULL, ctrl);
|
||||||
}
|
}
|
||||||
else if ((s=has_leading_keyword (line, "apdu_strerror")))
|
else if ((s=has_leading_keyword (line, "apdu_strerror")))
|
||||||
@ -2008,6 +2007,10 @@ cmd_getinfo (assuan_context_t ctx, char *line)
|
|||||||
s = apdu_strerror (ul);
|
s = apdu_strerror (ul);
|
||||||
rc = assuan_send_data (ctx, s, strlen (s));
|
rc = assuan_send_data (ctx, s, strlen (s));
|
||||||
}
|
}
|
||||||
|
else if (!strcmp (line, "dump_state"))
|
||||||
|
{
|
||||||
|
app_dump_state ();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
|
rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
Reference in New Issue
Block a user