From patchwork Thu Mar 22 18:20:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 148291 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 69522B6EF3 for ; Fri, 23 Mar 2012 05:22:04 +1100 (EST) Received: from localhost ([::1]:37133 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAmeA-0004KC-6r for incoming@patchwork.ozlabs.org; Thu, 22 Mar 2012 14:22:02 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAmdN-0002PS-Jc for qemu-devel@nongnu.org; Thu, 22 Mar 2012 14:21:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SAmdF-0001Xn-Ni for qemu-devel@nongnu.org; Thu, 22 Mar 2012 14:21:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1027) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAmdF-0001Vh-Gr for qemu-devel@nongnu.org; Thu, 22 Mar 2012 14:21:05 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2MIL41f018401 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 22 Mar 2012 14:21:04 -0400 Received: from garlic.tlv.redhat.com (spice-ovirt.tlv.redhat.com [10.35.4.71]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q2MIL0dj017650; Thu, 22 Mar 2012 14:21:03 -0400 From: Alon Levy To: qemu-devel@nongnu.org, rrelyea@redhat.com Date: Thu, 22 Mar 2012 20:20:58 +0200 Message-Id: <1332440459-17518-3-git-send-email-alevy@redhat.com> In-Reply-To: <1332440459-17518-1-git-send-email-alevy@redhat.com> References: <1332440459-17518-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] libcacard/vcard_emul_nss: handle no readers at startup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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; }