aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2024-08-02 11:44:57 +0000
committerWerner Koch <[email protected]>2024-08-07 08:20:19 +0000
commitb61430987665419bf8a4a7d5305103db181fecb4 (patch)
tree982f0b2a6346d10569737da274688dc9b6c58569
parentdoc: Fix URL to the OpenPGP card specs (diff)
downloadgnupg-b61430987665419bf8a4a7d5305103db181fecb4.tar.gz
gnupg-b61430987665419bf8a4a7d5305103db181fecb4.zip
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
-rw-r--r--scd/command.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/scd/command.c b/scd/command.c
index 7838cff11..9d8737572 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -1874,11 +1874,13 @@ static const char hlp_getinfo[] =
" - Return a list of active apps on all inserted cards.\n"
" cmd_has_option CMD 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"
" - Return a string for a status word.\n";
static gpg_error_t
cmd_getinfo (assuan_context_t ctx, char *line)
{
+ ctrl_t ctrl = assuan_get_pointer (ctx);
int rc = 0;
const char *s;
@@ -1898,6 +1900,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
&& (line[14] == ' ' || line[14] == '\t' || !line[14]))
{
char *cmd, *cmdopt;
+
line += 14;
while (*line == ' ' || *line == '\t')
line++;
@@ -1943,7 +1946,6 @@ cmd_getinfo (assuan_context_t ctx, char *line)
}
else if (!strcmp (line, "status"))
{
- ctrl_t ctrl = assuan_get_pointer (ctx);
char flag;
if (open_card (ctrl))
@@ -1980,13 +1982,11 @@ cmd_getinfo (assuan_context_t ctx, char *line)
}
else if (!strcmp (line, "card_list"))
{
- ctrl_t ctrl = assuan_get_pointer (ctx);
rc = app_send_card_list (ctrl);
}
else if (!strcmp (line, "active_apps"))
{
- ctrl_t ctrl = assuan_get_pointer (ctx);
card_t card = card_get (ctrl, NULL);
if (!card)
@@ -1999,7 +1999,6 @@ cmd_getinfo (assuan_context_t ctx, char *line)
}
else if (!strcmp (line, "all_active_apps"))
{
- ctrl_t ctrl = assuan_get_pointer (ctx);
rc = app_send_active_apps (NULL, ctrl);
}
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);
rc = assuan_send_data (ctx, s, strlen (s));
}
+ else if (!strcmp (line, "dump_state"))
+ {
+ app_dump_state ();
+ }
else
rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
return rc;