aboutsummaryrefslogtreecommitdiffstats
path: root/scd
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2024-08-02 11:44:57 +0000
committerWerner Koch <[email protected]>2024-08-02 11:44:57 +0000
commitf1e3a23d9e9014eb1f4322146a51f16793ded44a (patch)
tree8cbae4d7b73f8597541f840234423ef89c4345dd /scd
parentkeyboxd: New getinfo subcommand "connections". (diff)
downloadgnupg-f1e3a23d9e9014eb1f4322146a51f16793ded44a.tar.gz
gnupg-f1e3a23d9e9014eb1f4322146a51f16793ded44a.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
Diffstat (limited to 'scd')
-rw-r--r--scd/command.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/scd/command.c b/scd/command.c
index 6e1a6e223..b607523dd 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -1877,11 +1877,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;
@@ -1901,6 +1903,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++;
@@ -1946,7 +1949,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))
@@ -1983,13 +1985,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)
@@ -2002,7 +2002,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")))
@@ -2011,6 +2010,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;