aboutsummaryrefslogtreecommitdiffstats
path: root/agent/call-scd.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2025-03-17 16:37:08 +0000
committerWerner Koch <[email protected]>2025-03-17 16:37:08 +0000
commitf463586a9617392f68305a1059045ece1243475b (patch)
treeb53d5936f09ebddd1b769149424b3b7e1b19bdc7 /agent/call-scd.c
parentgpgconf: Fix reload and kill of keyboxd. (diff)
downloadgnupg-f463586a9617392f68305a1059045ece1243475b.tar.gz
gnupg-f463586a9617392f68305a1059045ece1243475b.zip
gpgsm: Extend --learn-card by an optional s/n argument.
* agent/command.c (cmd_learn): Allow for s/n argument. * agent/learncard.c (agent_handle_learn): Ditto. * agent/call-scd.c (agent_card_learn): Ditto. Pass it on to scd. * scd/command.c (cmd_switchcard): Factor most code out to ... (switchcard_core): new. (cmd_learn): Add option --demand to specify a s/n. * sm/gpgsm.c (main): Allow a s/n argument for --learn-card. -- This help Kleopatra to get a stable certificate listing. GnuPG-bug-id: 7379
Diffstat (limited to 'agent/call-scd.c')
-rw-r--r--agent/call-scd.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/agent/call-scd.c b/agent/call-scd.c
index de5d86271..28669206c 100644
--- a/agent/call-scd.c
+++ b/agent/call-scd.c
@@ -260,10 +260,14 @@ learn_status_cb (void *opaque, const char *line)
return err;
}
+
/* Perform the LEARN command and return a list of all private keys
- stored on the card. */
+ * stored on the card. If DEMAND_SN is given the info is returned for
+ * the card with that S/N instead of the current card. This may then
+ * switch the current card. */
int
agent_card_learn (ctrl_t ctrl,
+ const char *demand_sn,
void (*kpinfo_cb)(void*, const char *),
void *kpinfo_cb_arg,
void (*certinfo_cb)(void*, const char *),
@@ -273,6 +277,7 @@ agent_card_learn (ctrl_t ctrl,
{
int rc;
struct learn_parm_s parm;
+ char line[ASSUAN_LINELENGTH];
rc = start_scd (ctrl);
if (rc)
@@ -285,7 +290,13 @@ agent_card_learn (ctrl_t ctrl,
parm.certinfo_cb_arg = certinfo_cb_arg;
parm.sinfo_cb = sinfo_cb;
parm.sinfo_cb_arg = sinfo_cb_arg;
- rc = assuan_transact (daemon_ctx (ctrl), "LEARN --force",
+
+ if (demand_sn && *demand_sn)
+ snprintf (line, sizeof line, "LEARN --demand=%s --force", demand_sn);
+ else
+ snprintf (line, sizeof line, "LEARN --force");
+
+ rc = assuan_transact (daemon_ctx (ctrl), line,
NULL, NULL, NULL, NULL,
learn_status_cb, &parm);
if (rc)