- Try to fix pkcs11.hide_empty_slots
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@818 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
0ffa466eab
commit
1c22c55655
|
@ -259,8 +259,12 @@ static void pkcs15_init_slot(struct sc_pkcs15_card *card,
|
|||
if (auth != NULL) {
|
||||
pin_info = (struct sc_pkcs15_pin_info*) auth->data;
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%s (%s)",
|
||||
if (auth->label[0]) {
|
||||
snprintf(tmp, sizeof(tmp), "%s (%s)",
|
||||
card->label, auth->label);
|
||||
} else {
|
||||
snprintf(tmp, sizeof(tmp), "%s", card->label);
|
||||
}
|
||||
slot->token_info.flags |= CKF_LOGIN_REQUIRED;
|
||||
} else
|
||||
sprintf(tmp, "public");
|
||||
|
@ -389,11 +393,9 @@ static CK_RV pkcs15_create_tokens(struct sc_pkcs11_card *p11card)
|
|||
}
|
||||
|
||||
/* Create read/write slots */
|
||||
if (!sc_pkcs11_conf.hide_empty_slots) {
|
||||
while (slot_allocate(&slot, p11card) == CKR_OK) {
|
||||
pkcs15_init_token_info(card, &slot->token_info);
|
||||
slot->token_info.flags |= CKF_TOKEN_INITIALIZED;
|
||||
}
|
||||
while (slot_allocate(&slot, p11card) == CKR_OK) {
|
||||
pkcs15_init_token_info(card, &slot->token_info);
|
||||
slot->token_info.flags |= CKF_TOKEN_INITIALIZED;
|
||||
}
|
||||
|
||||
debug(context, "All tokens created\n");
|
||||
|
|
|
@ -97,8 +97,9 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese
|
|||
CK_SLOT_ID_PTR pSlotList, /* receives the array of slot IDs */
|
||||
CK_ULONG_PTR pulCount) /* receives the number of slots */
|
||||
{
|
||||
int numMatches, i, flags = 0;
|
||||
struct sc_pkcs11_slot *slot;
|
||||
CK_SLOT_ID found[SC_PKCS11_MAX_VIRTUAL_SLOTS];
|
||||
int numMatches, i;
|
||||
sc_pkcs11_slot_t *slot;
|
||||
|
||||
if (context == NULL_PTR)
|
||||
return CKR_CRYPTOKI_NOT_INITIALIZED;
|
||||
|
@ -108,13 +109,20 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese
|
|||
for (i=0; i<context->reader_count; i++)
|
||||
card_detect(i);
|
||||
|
||||
if (tokenPresent)
|
||||
flags |= CKF_TOKEN_PRESENT;
|
||||
|
||||
numMatches = 0;
|
||||
for (i=0, slot = virtual_slots; i<SC_PKCS11_MAX_VIRTUAL_SLOTS; i++, slot++)
|
||||
if (slot->card && (slot->slot_info.flags & flags) == flags)
|
||||
numMatches++;
|
||||
for (i=0; i<SC_PKCS11_MAX_VIRTUAL_SLOTS; i++) {
|
||||
slot = &virtual_slots[i];
|
||||
if (!slot->card)
|
||||
continue;
|
||||
if (tokenPresent && !(slot->slot_info.flags & CKF_TOKEN_PRESENT))
|
||||
continue;
|
||||
|
||||
/* Hide all empty slots */
|
||||
if (sc_pkcs11_conf.hide_empty_slots && !slot->fw_data)
|
||||
continue;
|
||||
|
||||
found[numMatches++] = i;
|
||||
}
|
||||
|
||||
if (pSlotList == NULL_PTR) {
|
||||
debug(context, "was only a size inquiry (%d)\n", numMatches);
|
||||
|
@ -128,11 +136,7 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese
|
|||
return CKR_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
numMatches = 0;
|
||||
for (i=0, slot = virtual_slots; i<SC_PKCS11_MAX_VIRTUAL_SLOTS; i++, slot++)
|
||||
if (slot->card && (slot->slot_info.flags & flags) == flags)
|
||||
pSlotList[numMatches++] = i;
|
||||
|
||||
memcpy(pSlotList, found, numMatches * sizeof(CK_SLOT_ID));
|
||||
*pulCount = numMatches;
|
||||
|
||||
debug(context, "returned %d slots\n", numMatches);
|
||||
|
|
Loading…
Reference in New Issue