Generalized configuration option `ignored_readers`

This commit is contained in:
Frank Morgner 2018-01-30 16:05:58 +01:00
parent 4fca7d08c1
commit d11e05fe1f
4 changed files with 34 additions and 24 deletions

View File

@ -38,6 +38,14 @@ app default {
# Default: false
# enable_default_driver = true;
# List of readers to ignore
# If any of the strings listed below is matched in a reader name (case
# sensitive, partial matching possible), the reader is ignored by OpenSC.
# Use `opensc-tool --list-readers` to see all currently connected readers.
#
# Default: empty
# ignored_readers = "CardMan 1021", "SPR 532";
# CT-API module configuration.
reader_driver ctapi {
# module @LIBDIR@@LIB_PRE@towitoko@DYN_LIB_EXT@ {
@ -1101,13 +1109,6 @@ 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 sensitive) in a reader name,
# the reader is ignored by the PKCS#11 module.
#
# Default: empty
# ignored_readers = "CardMan 1021", "SPR 532";
# Symbolic names of PINs for which slots are created
# Card can contain more then one PINs or more then one on-card application with
# its own PINs. Normally, to access all of them with the PKCS#11 API a slot has to be

View File

@ -39,9 +39,31 @@
#include "common/libscdl.h"
#include "internal.h"
static int ignored_reader(sc_context_t *ctx, sc_reader_t *reader)
{
if (ctx != NULL && reader != NULL && reader->name != NULL) {
size_t i;
const scconf_list *list;
for (i = 0; ctx->conf_blocks[i]; i++) {
list = scconf_find_list(ctx->conf_blocks[i], "ignored_readers");
while (list != NULL) {
if (strstr(reader->name, list->data) != NULL) {
sc_log(ctx, "Ignoring reader \'%s\' because of \'%s\'\n",
reader->name, list->data);
return 1;
}
list = list->next;
}
}
}
return 0;
}
int _sc_add_reader(sc_context_t *ctx, sc_reader_t *reader)
{
if (reader == NULL) {
if (reader == NULL || ignored_reader(ctx, reader)) {
return SC_ERROR_INVALID_ARGUMENTS;
}
reader->ctx = ctx;

View File

@ -1262,7 +1262,9 @@ int pcsc_add_reader(sc_context_t *ctx,
ret = _sc_add_reader(ctx, reader);
refresh_attributes(reader);
if (ret == SC_SUCCESS) {
refresh_attributes(reader);
}
err1:
return ret;

View File

@ -155,21 +155,6 @@ 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 (strstr(reader->name, list->data) != NULL) {
sc_log(context, "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)