From f463586a9617392f68305a1059045ece1243475b Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 17 Mar 2025 17:37:08 +0100 Subject: 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 --- agent/command.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'agent/command.c') diff --git a/agent/command.c b/agent/command.c index b61ab9354..ff018dde7 100644 --- a/agent/command.c +++ b/agent/command.c @@ -2376,27 +2376,31 @@ cmd_get_confirmation (assuan_context_t ctx, char *line) static const char hlp_learn[] = - "LEARN [--send] [--sendinfo] [--force]\n" + "LEARN [--send] [--sendinfo] [--force] [SERIALNO]\n" "\n" "Learn something about the currently inserted smartcard. With\n" "--sendinfo information about the card is returned; with --send\n" "the available certificates are returned as D lines; with --force\n" - "private key storage will be updated by the result."; + "private key storage will be updated by the result. With SERIALNO\n" + "given the current card is first switched to the specified one."; static gpg_error_t cmd_learn (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); gpg_error_t err; int send, sendinfo, force; + const char *demand_sn; send = has_option (line, "--send"); sendinfo = send? 1 : has_option (line, "--sendinfo"); force = has_option (line, "--force"); + line = skip_options (line); + demand_sn = *line? line : NULL; if (ctrl->restricted) return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN)); - err = agent_handle_learn (ctrl, send, sendinfo? ctx : NULL, force); + err = agent_handle_learn (ctrl, send, sendinfo? ctx : NULL, force, demand_sn); return leave_cmd (ctx, err); } -- cgit v1.2.3