From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xj4ME-0001ew-H2 for qemu-devel@nongnu.org; Tue, 28 Oct 2014 06:50:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xj4M6-0002Qj-3F for qemu-devel@nongnu.org; Tue, 28 Oct 2014 06:50:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xj4M5-0002QL-S7 for qemu-devel@nongnu.org; Tue, 28 Oct 2014 06:50:26 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9SAoPxY007429 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 28 Oct 2014 06:50:25 -0400 From: Gerd Hoffmann Date: Tue, 28 Oct 2014 11:50:18 +0100 Message-Id: <1414493422-4422-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1414493422-4422-1-git-send-email-kraxel@redhat.com> References: <1414493422-4422-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 1/5] libcacard: introduce new vcard_emul_logout List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Ray Strode , Gerd Hoffmann From: Ray Strode vcard_emul_reset currently only logs NSS out, but there is a TODO for potentially sending insertion/removal events when powering down or powering up. For clarity, this commit moves the current guts of vcard_emul_reset to a new vcard_emul_logout function which will never send insertion/removal events. The vcard_emul_reset function now just calls vcard_emul_logout, but also retains its TODO for watching power state transitions and sending insertion/removal events. Signed-off-by: Ray Strode Reviewed-By: Robert Relyea Reviewed-By: Alon Levy Signed-off-by: Gerd Hoffmann --- libcacard/vcard_emul.h | 1 + libcacard/vcard_emul_nss.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libcacard/vcard_emul.h b/libcacard/vcard_emul.h index 963563f..f09ee98 100644 --- a/libcacard/vcard_emul.h +++ b/libcacard/vcard_emul.h @@ -40,6 +40,7 @@ int vcard_emul_get_login_count(VCard *card); /* login into the card, return the 7816 status word (sw2 || sw1) */ vcard_7816_status_t vcard_emul_login(VCard *card, unsigned char *pin, int pin_len); +void vcard_emul_logout(VCard *card); /* * key functions diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c index 07b4464..950edee 100644 --- a/libcacard/vcard_emul_nss.c +++ b/libcacard/vcard_emul_nss.c @@ -401,7 +401,7 @@ vcard_emul_login(VCard *card, unsigned char *pin, int pin_len) } void -vcard_emul_reset(VCard *card, VCardPower power) +vcard_emul_logout(VCard *card) { PK11SlotInfo *slot; @@ -409,16 +409,24 @@ vcard_emul_reset(VCard *card, VCardPower power) return; } + slot = vcard_emul_card_get_slot(card); + if (PK11_IsLoggedIn(slot, NULL)) { + PK11_Logout(slot); /* NOTE: ignoring SECStatus return value */ + } +} + +void +vcard_emul_reset(VCard *card, VCardPower power) +{ /* * if we reset the card (either power on or power off), we lose our login * state */ + vcard_emul_logout(card); + /* TODO: we may also need to send insertion/removal events? */ - slot = vcard_emul_card_get_slot(card); - PK11_Logout(slot); /* NOTE: ignoring SECStatus return value */ } - static VReader * vcard_emul_find_vreader_from_slot(PK11SlotInfo *slot) { -- 1.8.3.1