Skip to content

Commit d120209

Browse files
committed
Force re-scan of devices during recovery
6eac006 was a little too aggressive about the caching thing.
1 parent 6eac006 commit d120209

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

ebox-cmd.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,19 @@ local_unlock_agent(struct piv_ecdh_box *box)
367367
return (err);
368368
}
369369

370+
void
371+
release_context(void)
372+
{
373+
if (ebox_ctx_init) {
374+
if (ebox_enum_tokens != NULL) {
375+
piv_release(ebox_enum_tokens);
376+
ebox_enum_tokens = NULL;
377+
}
378+
SCardReleaseContext(ebox_ctx);
379+
ebox_ctx_init = B_FALSE;
380+
}
381+
}
382+
370383
errf_t *
371384
local_unlock(struct piv_ecdh_box *box, struct sshkey *cak, const char *name)
372385
{
@@ -484,7 +497,8 @@ local_unlock(struct piv_ecdh_box *box, struct sshkey *cak, const char *name)
484497
err = ERRF_OK;
485498

486499
out:
487-
piv_release(tokens);
500+
if (tokens != ebox_enum_tokens)
501+
piv_release(tokens);
488502
return (err);
489503
}
490504

@@ -934,6 +948,7 @@ interactive_recovery(struct ebox_config *config, const char *what)
934948
fprintf(stderr, "-- Local device %s --\n",
935949
state->ps_ans->a_text);
936950
partagain:
951+
release_context();
937952
error = local_unlock(ebox_part_box(part),
938953
ebox_tpl_part_cak(tpart), ebox_tpl_part_name(tpart));
939954
if (error && !errf_caused_by(error, "NotFoundError"))

ebox-cmd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ enum ebox_exit_status {
6363
#define EBOX_MAX_SIZE 16384
6464
#define BASE64_LINE_LEN 65
6565

66+
void release_context(void);
67+
6668
char *piv_token_shortid(struct piv_token *pk);
6769
const char *pin_type_to_name(enum piv_pin type);
6870
void assert_pin(struct piv_token *pk, const char *partname, boolean_t prompt);

pivy-box.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ interactive_unlock_ebox(struct ebox *ebox)
942942
if (ebox_tpl_config_type(tconfig) == EBOX_PRIMARY) {
943943
part = ebox_config_next_part(config, NULL);
944944
tpart = ebox_part_tpl(part);
945+
release_context();
945946
error = local_unlock(ebox_part_box(part),
946947
ebox_tpl_part_cak(tpart),
947948
ebox_tpl_part_name(tpart));

pivy-luks.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ unlock_or_recover(struct ebox *ebox, const char *descr, boolean_t *recovered)
154154
if (ebox_tpl_config_type(tconfig) == EBOX_PRIMARY) {
155155
part = ebox_config_next_part(config, NULL);
156156
tpart = ebox_part_tpl(part);
157+
release_context();
157158
error = local_unlock(ebox_part_box(part),
158159
ebox_tpl_part_cak(tpart),
159160
ebox_tpl_part_name(tpart));

pivy-zfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ unlock_or_recover(struct ebox *ebox, const char *descr, boolean_t *recovered)
156156
if (ebox_tpl_config_type(tconfig) == EBOX_PRIMARY) {
157157
part = ebox_config_next_part(config, NULL);
158158
tpart = ebox_part_tpl(part);
159+
release_context();
159160
error = local_unlock(ebox_part_box(part),
160161
ebox_tpl_part_cak(tpart),
161162
ebox_tpl_part_name(tpart));

0 commit comments

Comments
 (0)