1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

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 <wk@gnupg.org>
This commit is contained in:
Werner Koch 2020-06-30 14:39:32 +02:00
parent fb10b6cba4
commit 58b091df83
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -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);