diff options
author | Werner Koch <[email protected]> | 2020-06-30 12:39:32 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2020-06-30 12:41:49 +0000 |
commit | 58b091df831f61c8d3551114f2480d36e73de2da (patch) | |
tree | a73d43616b99e6b76a78c74eb1a60be3ed89ed11 | |
parent | card: Better detect removed cards. Add TCOS PIN menu. (diff) | |
download | gnupg-58b091df831f61c8d3551114f2480d36e73de2da.tar.gz gnupg-58b091df831f61c8d3551114f2480d36e73de2da.zip |
scd: Change how the removed card flag is set.
* scd/command.c (cmd_serialno): Set/clear card removed flags for all
connections using the current card.
--
This seems to solve the problems I had in gpg-card and ssh. I am not
sure why the old code was done this way - maybe an oversight when
adding support for multiple cards.
Signed-off-by: Werner Koch <[email protected]>
-rw-r--r-- | scd/command.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/scd/command.c b/scd/command.c index f0c3b86a2..800156ca5 100644 --- a/scd/command.c +++ b/scd/command.c @@ -307,6 +307,7 @@ cmd_serialno (assuan_context_t ctx, char *line) char *serial; const char *demand; int opt_all = has_option (line, "--all"); + int thisslot; if ( IS_LOCKED (ctrl) ) return gpg_error (GPG_ERR_LOCKED); @@ -327,22 +328,22 @@ cmd_serialno (assuan_context_t ctx, char *line) line = skip_options (line); /* Clear the remove flag so that the open_card is able to reread it. */ - if (ctrl->server_local->card_removed) - ctrl->server_local->card_removed = 0; - - if ((rc = open_card_with_request (ctrl, *line? line:NULL, demand, opt_all))) - { - ctrl->server_local->card_removed = 1; - return rc; - } - - /* Success, clear the card_removed flag for all sessions. */ + ctrl->server_local->card_removed = 0; + rc = open_card_with_request (ctrl, *line? line:NULL, demand, opt_all); + /* Now clear or set the card_removed flag for all sessions using the + * current slot. In the error case make sure that the flag is set + * for the current session. */ + thisslot = ctrl->card_ctx? ctrl->card_ctx->slot : -1; for (sl=session_list; sl; sl = sl->next_session) { ctrl_t c = sl->ctrl_backlink; - - if (c != ctrl) - c->server_local->card_removed = 0; + if (c && c->card_ctx && c->card_ctx->slot == thisslot) + c->server_local->card_removed = rc? 1 : 0; + } + if (rc) + { + ctrl->server_local->card_removed = 1; + return rc; } serial = card_get_serialno (ctrl->card_ctx); |