Limit virtual OpenCT readers to a sane default of 2 readers/tokens by default.

Most users don't use more than one or two tokens concurrently. This way default configuration (or with no configuration file) works even after you insert a PC/SC reader as OpenCT does not "eat up" all PKCS#11 slots with 5 virtual readers.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3618 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
martin 2009-01-16 16:12:50 +00:00
parent 300dfeb088
commit c6f753dc00
2 changed files with 14 additions and 23 deletions

View File

@ -69,8 +69,8 @@ app default {
# to set these values. For usb devices check the
# properties with lsusb -vv for dwMaxIFSD
#
#max_send_size = 252;
#max_recv_size = 252;
# max_send_size = 252;
# max_recv_size = 252;
# Connect to reader in exclusive mode.
# Default: false
@ -93,18 +93,19 @@ app default {
# provider_library = @DEFAULT_PCSC_PROVIDER@
}
# options for openct support
# Options for OpenCT support
reader_driver openct {
# virtual readers to allocate. default:5
readers = 5;
# Virtual readers to allocate.
# Default: 2
# readers = 5;
# This sets the maximum send and receive sizes.
# Some reader drivers have limitations, so you need
# to set these values. For usb devices check the
# properties with lsusb -vv for dwMaxIFSD
#
#max_send_size = 252;
#max_recv_size = 252;
# max_send_size = 252;
# max_recv_size = 252;
};
# What card drivers to load at start-up

View File

@ -21,16 +21,6 @@
#include <openct/logging.h>
#include <openct/error.h>
/* If you set PREALLOCATE to a non-zero value, this backend
* will allocate that many reader slots. This will allow hot-
* plugging devices (such as USB tokens) while OpenSC is running.
*
* To disable this, set PREALLOCATE to 0.
*
* This will most likely become a config file option soon.
*/
#define PREALLOCATE 5
/* function declarations */
static int openct_reader_init(sc_context_t *ctx, void **priv_data);
static int openct_add_reader(sc_context_t *ctx, unsigned int num, ct_info_t *info);
@ -83,24 +73,24 @@ struct slot_data {
static int
openct_reader_init(sc_context_t *ctx, void **priv_data)
{
unsigned int i,max;
unsigned int i,max_virtual;
scconf_block *conf_block;
SC_FUNC_CALLED(ctx, 1);
max=OPENCT_MAX_READERS;
conf_block = sc_get_conf_block(ctx, "reader_driver", "openct", 1);
max_virtual = 2;
conf_block = sc_get_conf_block(ctx, "reader_driver", "openct", 1);
if (conf_block) {
max = scconf_get_int(conf_block, "readers", OPENCT_MAX_READERS);
max_virtual = scconf_get_int(conf_block, "readers", max_virtual);
}
for (i = 0; i < max; i++) {
for (i = 0; i < OPENCT_MAX_READERS; i++) {
ct_info_t info;
if (ct_reader_info(i, &info) >= 0) {
openct_add_reader(ctx, i, &info);
} else if (i < PREALLOCATE) {
} else if (i < max_virtual) {
openct_add_reader(ctx, i, NULL);
}
}