Merge remote-tracking branch 'alon/libcacard' into staging
* alon/libcacard: libcacard/vcard_emul_nss: add warning for old coolkey libcacard/vcard_emul_nss: handle no readers at startup libcacard/vcard_emul_nss: don't stop thread when there are no slots
This commit is contained in:
commit
0a5a4e0568
@ -682,8 +682,19 @@ vcard_emul_event_thread(void *arg)
|
|||||||
SECMODModule *module = (SECMODModule *)arg;
|
SECMODModule *module = (SECMODModule *)arg;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
/*
|
||||||
|
* XXX - the latency value doesn't matter one bit. you only get no
|
||||||
|
* blocking (flags |= CKF_DONT_BLOCK) or PKCS11_WAIT_LATENCY (==500),
|
||||||
|
* hard coded in coolkey. And it isn't coolkey's fault - the timeout
|
||||||
|
* value we pass get's dropped on the floor before C_WaitForSlotEvent
|
||||||
|
* is called.
|
||||||
|
*/
|
||||||
slot = SECMOD_WaitForAnyTokenEvent(module, 0, 500);
|
slot = SECMOD_WaitForAnyTokenEvent(module, 0, 500);
|
||||||
if (slot == NULL) {
|
if (slot == NULL) {
|
||||||
|
/* this could be just a no event indication */
|
||||||
|
if (PORT_GetError() == SEC_ERROR_NO_EVENT) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vreader = vcard_emul_find_vreader_from_slot(slot);
|
vreader = vcard_emul_find_vreader_from_slot(slot);
|
||||||
@ -994,10 +1005,10 @@ vcard_emul_init(const VCardEmulOptions *options)
|
|||||||
SECMOD_GetReadLock(module_lock);
|
SECMOD_GetReadLock(module_lock);
|
||||||
for (mlp = module_list; mlp; mlp = mlp->next) {
|
for (mlp = module_list; mlp; mlp = mlp->next) {
|
||||||
SECMODModule *module = mlp->module;
|
SECMODModule *module = mlp->module;
|
||||||
PRBool has_emul_slots = PR_FALSE;
|
|
||||||
|
|
||||||
if (module == NULL) {
|
/* Ignore the internal module */
|
||||||
continue;
|
if (module == NULL || module == SECMOD_GetInternalModule()) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < module->slotCount; i++) {
|
for (i = 0; i < module->slotCount; i++) {
|
||||||
@ -1007,15 +1018,22 @@ vcard_emul_init(const VCardEmulOptions *options)
|
|||||||
if (slot == NULL || !PK11_IsRemovable(slot) || !PK11_IsHW(slot)) {
|
if (slot == NULL || !PK11_IsRemovable(slot) || !PK11_IsHW(slot)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (strcmp("E-Gate 0 0", PK11_GetSlotName(slot)) == 0) {
|
||||||
|
/*
|
||||||
|
* coolkey <= 1.1.0-20 emulates this reader if it can't find
|
||||||
|
* any hardware readers. This causes problems, warn user of
|
||||||
|
* problems.
|
||||||
|
*/
|
||||||
|
fprintf(stderr, "known bad coolkey version - see "
|
||||||
|
"https://bugzilla.redhat.com/show_bug.cgi?id=802435\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
vreader_emul = vreader_emul_new(slot, options->hw_card_type,
|
vreader_emul = vreader_emul_new(slot, options->hw_card_type,
|
||||||
options->hw_type_params);
|
options->hw_type_params);
|
||||||
vreader = vreader_new(PK11_GetSlotName(slot), vreader_emul,
|
vreader = vreader_new(PK11_GetSlotName(slot), vreader_emul,
|
||||||
vreader_emul_delete);
|
vreader_emul_delete);
|
||||||
vreader_add_reader(vreader);
|
vreader_add_reader(vreader);
|
||||||
|
|
||||||
has_readers = PR_TRUE;
|
|
||||||
has_emul_slots = PR_TRUE;
|
|
||||||
|
|
||||||
if (PK11_IsPresent(slot)) {
|
if (PK11_IsPresent(slot)) {
|
||||||
VCard *vcard;
|
VCard *vcard;
|
||||||
vcard = vcard_emul_mirror_card(vreader);
|
vcard = vcard_emul_mirror_card(vreader);
|
||||||
@ -1024,12 +1042,10 @@ vcard_emul_init(const VCardEmulOptions *options)
|
|||||||
vcard_free(vcard);
|
vcard_free(vcard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (has_emul_slots) {
|
vcard_emul_new_event_thread(module);
|
||||||
vcard_emul_new_event_thread(module);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
SECMOD_ReleaseReadLock(module_lock);
|
SECMOD_ReleaseReadLock(module_lock);
|
||||||
nss_emul_init = has_readers;
|
nss_emul_init = PR_TRUE;
|
||||||
|
|
||||||
return VCARD_EMUL_OK;
|
return VCARD_EMUL_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user