Implement simple reader ignoring, to exclude readers from OpenSC PKCS#11 module.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4624 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
martin 2010-08-15 09:33:18 +00:00
parent 409284ed60
commit a938d3b67f
2 changed files with 23 additions and 1 deletions

View File

@ -404,6 +404,13 @@ app opensc-pkcs11 {
#
# Default: false
# zero_ckaid_for_ca_certs = true;
# List of readers to ignore
# If any of the strings listed below is matched (case ignored) in a reader name,
# the reader is ignored by the PKCS#11 module.
#
# Default: empty
# ignored_readers = "cardman 1021", "SPR 532";
}
}

View File

@ -107,6 +107,21 @@ CK_RV initialize_reader(sc_reader_t *reader)
unsigned int i;
CK_RV rv;
scconf_block *conf_block = NULL;
const scconf_list *list = NULL;
conf_block = sc_get_conf_block(context, "pkcs11", NULL, 1);
if (conf_block != NULL) {
list = scconf_find_list(conf_block, "ignored_readers");
while (list != NULL) {
if (strcasestr(reader->name, list->data) != NULL) {
sc_debug(context, SC_LOG_DEBUG_NORMAL, "Ignoring reader \'%s\' because of \'%s\'\n", reader->name, list->data);
return CKR_OK;
}
list = list->next;
}
}
for (i = 0; i < sc_pkcs11_conf.slots_per_card; i++) {
rv = create_slot(reader);
if (rv != CKR_OK)
@ -371,7 +386,7 @@ CK_RV slot_find_changed(CK_SLOT_ID_PTR idp, int mask)
slot->events &= ~SC_EVENT_CARD_INSERTED;
}
sc_debug(context, SC_LOG_DEBUG_NORMAL, "mask: 0x%02X events: 0x%02X result: %d", mask, slot->events, (slot->events & mask));
if (slot->events & mask) {
slot->events &= ~mask;
*idp = slot->id;