qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] libcacard: handle no readers on startup
@ 2012-03-22 18:20 Alon Levy
  2012-03-22 18:20 ` [Qemu-devel] [PATCH 1/3] libcacard/vcard_emul_nss: don't stop thread when there are no slots Alon Levy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alon Levy @ 2012-03-22 18:20 UTC (permalink / raw)
  To: qemu-devel, rrelyea

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=802435 together with
patches for coolkey. coolkey patches are at:

 git://people.freedesktop.org/~alon/coolkey bz806038.remove_fake

Alon Levy (3):
  libcacard/vcard_emul_nss: don't stop thread when there are no slots
  libcacard/vcard_emul_nss: handle no readers at startup
  libcacard/vcard_emul_nss: add warning for old coolkey

 libcacard/vcard_emul_nss.c |   36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

-- 
1.7.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH 1/3] libcacard/vcard_emul_nss: don't stop thread when there are no slots
  2012-03-22 18:20 [Qemu-devel] [PATCH 0/3] libcacard: handle no readers on startup Alon Levy
@ 2012-03-22 18:20 ` Alon Levy
  2012-03-22 18:20 ` [Qemu-devel] [PATCH 2/3] libcacard/vcard_emul_nss: handle no readers at startup Alon Levy
  2012-03-22 18:20 ` [Qemu-devel] [PATCH 3/3] libcacard/vcard_emul_nss: add warning for old coolkey Alon Levy
  2 siblings, 0 replies; 4+ messages in thread
From: Alon Levy @ 2012-03-22 18:20 UTC (permalink / raw)
  To: qemu-devel, rrelyea

Signed-off-by: Alon Levy <alevy@redhat.com>
---
 libcacard/vcard_emul_nss.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index bdc3c79..7de5d5b 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -682,8 +682,19 @@ vcard_emul_event_thread(void *arg)
     SECMODModule *module = (SECMODModule *)arg;
 
     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);
         if (slot == NULL) {
+            /* this could be just a no event indication */
+            if (PORT_GetError() == SEC_ERROR_NO_EVENT) {
+                continue;
+            }
             break;
         }
         vreader = vcard_emul_find_vreader_from_slot(slot);
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH 2/3] libcacard/vcard_emul_nss: handle no readers at startup
  2012-03-22 18:20 [Qemu-devel] [PATCH 0/3] libcacard: handle no readers on startup Alon Levy
  2012-03-22 18:20 ` [Qemu-devel] [PATCH 1/3] libcacard/vcard_emul_nss: don't stop thread when there are no slots Alon Levy
@ 2012-03-22 18:20 ` Alon Levy
  2012-03-22 18:20 ` [Qemu-devel] [PATCH 3/3] libcacard/vcard_emul_nss: add warning for old coolkey Alon Levy
  2 siblings, 0 replies; 4+ messages in thread
From: Alon Levy @ 2012-03-22 18:20 UTC (permalink / raw)
  To: qemu-devel, rrelyea

When starting with no readers, coolkey should show no slots (with
RHBZ 806038 fixed). Fix initialization to launch the event handling
thread for each module that isn't the internal module regardless of the
number of slots detected for it at initialization time, since slot
number may start as 0 and is dynamic.

RHBZ: 802435
Signed-off-by: Alon Levy <alevy@redhat.com>
---
 libcacard/vcard_emul_nss.c |   15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 7de5d5b..3703fdc 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -1005,10 +1005,10 @@ vcard_emul_init(const VCardEmulOptions *options)
     SECMOD_GetReadLock(module_lock);
     for (mlp = module_list; mlp; mlp = mlp->next) {
         SECMODModule *module = mlp->module;
-        PRBool has_emul_slots = PR_FALSE;
 
-        if (module == NULL) {
-                continue;
+        /* Ignore the internal module */
+        if (module == NULL || module == SECMOD_GetInternalModule()) {
+            continue;
         }
 
         for (i = 0; i < module->slotCount; i++) {
@@ -1024,9 +1024,6 @@ vcard_emul_init(const VCardEmulOptions *options)
                                   vreader_emul_delete);
             vreader_add_reader(vreader);
 
-            has_readers = PR_TRUE;
-            has_emul_slots = PR_TRUE;
-
             if (PK11_IsPresent(slot)) {
                 VCard *vcard;
                 vcard = vcard_emul_mirror_card(vreader);
@@ -1035,12 +1032,10 @@ vcard_emul_init(const VCardEmulOptions *options)
                 vcard_free(vcard);
             }
         }
-        if (has_emul_slots) {
-            vcard_emul_new_event_thread(module);
-        }
+        vcard_emul_new_event_thread(module);
     }
     SECMOD_ReleaseReadLock(module_lock);
-    nss_emul_init = has_readers;
+    nss_emul_init = PR_TRUE;
 
     return VCARD_EMUL_OK;
 }
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH 3/3] libcacard/vcard_emul_nss: add warning for old coolkey
  2012-03-22 18:20 [Qemu-devel] [PATCH 0/3] libcacard: handle no readers on startup Alon Levy
  2012-03-22 18:20 ` [Qemu-devel] [PATCH 1/3] libcacard/vcard_emul_nss: don't stop thread when there are no slots Alon Levy
  2012-03-22 18:20 ` [Qemu-devel] [PATCH 2/3] libcacard/vcard_emul_nss: handle no readers at startup Alon Levy
@ 2012-03-22 18:20 ` Alon Levy
  2 siblings, 0 replies; 4+ messages in thread
From: Alon Levy @ 2012-03-22 18:20 UTC (permalink / raw)
  To: qemu-devel, rrelyea

Older coolkey versions (before the future fix of RHBZ 802435) have
a fake card reader created if no reader is detected during module
initialization. Warn libcacard users if the faulty coolkey is detected
by checking for the fake reader name "E-Gate 0 0".

Signed-off-by: Alon Levy <alevy@redhat.com>
---
 libcacard/vcard_emul_nss.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 3703fdc..802cae3 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -1018,6 +1018,16 @@ vcard_emul_init(const VCardEmulOptions *options)
             if (slot == NULL || !PK11_IsRemovable(slot) || !PK11_IsHW(slot)) {
                 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,
                                             options->hw_type_params);
             vreader = vreader_new(PK11_GetSlotName(slot), vreader_emul,
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-03-22 18:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-22 18:20 [Qemu-devel] [PATCH 0/3] libcacard: handle no readers on startup Alon Levy
2012-03-22 18:20 ` [Qemu-devel] [PATCH 1/3] libcacard/vcard_emul_nss: don't stop thread when there are no slots Alon Levy
2012-03-22 18:20 ` [Qemu-devel] [PATCH 2/3] libcacard/vcard_emul_nss: handle no readers at startup Alon Levy
2012-03-22 18:20 ` [Qemu-devel] [PATCH 3/3] libcacard/vcard_emul_nss: add warning for old coolkey Alon Levy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).