mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02: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:
parent
fb10b6cba4
commit
58b091df83
@ -307,6 +307,7 @@ cmd_serialno (assuan_context_t ctx, char *line)
|
|||||||
char *serial;
|
char *serial;
|
||||||
const char *demand;
|
const char *demand;
|
||||||
int opt_all = has_option (line, "--all");
|
int opt_all = has_option (line, "--all");
|
||||||
|
int thisslot;
|
||||||
|
|
||||||
if ( IS_LOCKED (ctrl) )
|
if ( IS_LOCKED (ctrl) )
|
||||||
return gpg_error (GPG_ERR_LOCKED);
|
return gpg_error (GPG_ERR_LOCKED);
|
||||||
@ -327,22 +328,22 @@ cmd_serialno (assuan_context_t ctx, char *line)
|
|||||||
line = skip_options (line);
|
line = skip_options (line);
|
||||||
|
|
||||||
/* Clear the remove flag so that the open_card is able to reread it. */
|
/* 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;
|
||||||
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
|
||||||
if ((rc = open_card_with_request (ctrl, *line? line:NULL, demand, opt_all)))
|
* current slot. In the error case make sure that the flag is set
|
||||||
{
|
* for the current session. */
|
||||||
ctrl->server_local->card_removed = 1;
|
thisslot = ctrl->card_ctx? ctrl->card_ctx->slot : -1;
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Success, clear the card_removed flag for all sessions. */
|
|
||||||
for (sl=session_list; sl; sl = sl->next_session)
|
for (sl=session_list; sl; sl = sl->next_session)
|
||||||
{
|
{
|
||||||
ctrl_t c = sl->ctrl_backlink;
|
ctrl_t c = sl->ctrl_backlink;
|
||||||
|
if (c && c->card_ctx && c->card_ctx->slot == thisslot)
|
||||||
if (c != ctrl)
|
c->server_local->card_removed = rc? 1 : 0;
|
||||||
c->server_local->card_removed = 0;
|
}
|
||||||
|
if (rc)
|
||||||
|
{
|
||||||
|
ctrl->server_local->card_removed = 1;
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
serial = card_get_serialno (ctrl->card_ctx);
|
serial = card_get_serialno (ctrl->card_ctx);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user