summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrrelyea <rrelyea@fba4d07e-fe0f-4d7f-8147-e0026e666dc0>2011-07-13 22:19:42 +0000
committerrrelyea <rrelyea@fba4d07e-fe0f-4d7f-8147-e0026e666dc0>2011-07-13 22:19:42 +0000
commit117d960a4c91c9fdc266aa2ec5fdf5f797a59747 (patch)
tree65df9ef9261654fb50894e086390e74db7a56bae
parentd7cb68a78b16605f8e722073ba009bd249cd6193 (diff)
Handle pcscd restarting.
git-svn-id: http://svn.fedorahosted.org/svn/coolkey/trunk@95 fba4d07e-fe0f-4d7f-8147-e0026e666dc0
-rw-r--r--src/coolkey/Makefile.am2
-rw-r--r--src/coolkey/slot.cpp17
-rw-r--r--src/libckyapplet/cky_card.c5
3 files changed, 19 insertions, 5 deletions
diff --git a/src/coolkey/Makefile.am b/src/coolkey/Makefile.am
index 4d5b6fe..aeb0830 100644
--- a/src/coolkey/Makefile.am
+++ b/src/coolkey/Makefile.am
@@ -64,7 +64,7 @@ libcoolkeypk11_la_LIBADD = @LIBCKYAPPLET@ $(ZLIB_LIBS)
# coreconf .def file to a simplistic but acceptable libtool .sym file
#
coolkeypk11.sym: coolkeypk11.def
- grep -v ';+' $< | grep -v ';-' | sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' > $@
+ grep -v ';+' $< | grep -v ';-' | sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' | grep -v '^$$'> $@
clean-generic:
rm -f coolkeypk11.sym
diff --git a/src/coolkey/slot.cpp b/src/coolkey/slot.cpp
index dd1db32..0c69826 100644
--- a/src/coolkey/slot.cpp
+++ b/src/coolkey/slot.cpp
@@ -237,9 +237,14 @@ SlotList::updateReaderList()
CKYStatus status = CKYCardContext_ListReaders(context, &readerNames);
if ( status != CKYSUCCESS ) {
- throw PKCS11Exception(CKR_GENERAL_ERROR,
- "Failed to list readers: 0x%x\n",
- CKYCardContext_GetLastError(context));
+ /* if the service is stopped, treat it as if we have no readers */
+ if ((CKYCardContext_GetLastError(context) != SCARD_E_NO_SERVICE) &&
+ (CKYCardContext_GetLastError(context) != SCARD_E_SERVICE_STOPPED)) {
+ throw PKCS11Exception(CKR_GENERAL_ERROR,
+ "Failed to list readers: 0x%x\n",
+ CKYCardContext_GetLastError(context));
+ }
+
}
if (!readerStates) {
@@ -1286,7 +1291,9 @@ SlotList::waitForSlotEvent(CK_FLAGS flag, CK_SLOT_ID_PTR slotp, CK_VOID_PTR res)
#endif
} while ((status == CKYSUCCESS) ||
(CKYCardContext_GetLastError(context) == SCARD_E_TIMEOUT) ||
- ( CKYCardContext_GetLastError(context) == SCARD_E_READER_UNAVAILABLE));
+ (CKYCardContext_GetLastError(context) == SCARD_E_READER_UNAVAILABLE) ||
+ (CKYCardContext_GetLastError(context) == SCARD_E_NO_SERVICE) ||
+ (CKYCardContext_GetLastError(context) == SCARD_E_SERVICE_STOPPED) );
#else
do {
OSSleep(100);
@@ -3405,10 +3412,12 @@ retry:
status = CKYApplet_ComputeCrypt(conn, keyNum, CKY_RSA_NO_PAD, direction,
input, NULL, output, getNonce(), &result);
}
+#ifdef notdef /* CAC pin cachine is incomplete, don't enable it */
/* map the ISO not logged in code to the coolkey one */
if (status == CKYISO_CONDITION_NOT_SATISFIED) {
status = (CKYStatus) CKYISO_UNAUTHORIZED;
}
+#endif
if (status != CKYSUCCESS) {
if ( status == CKYSCARDERR ) {
handleConnectionError();
diff --git a/src/libckyapplet/cky_card.c b/src/libckyapplet/cky_card.c
index e613961..325fe6a 100644
--- a/src/libckyapplet/cky_card.c
+++ b/src/libckyapplet/cky_card.c
@@ -849,6 +849,11 @@ CKYCardContext_WaitForStatusChange(CKYCardContext *ctx,
rv = ctx->scard->SCardGetStatusChange(ctx->context, timeout,
readers, readerCount);
if (rv != SCARD_S_SUCCESS) {
+ if ((rv == SCARD_E_NO_SERVICE) || (rv == SCARD_E_SERVICE_STOPPED)) {
+ /* if we were stopped, don't reuse the old context,
+ * pcsc-lite hangs */
+ ckyCardContext_release(ctx);
+ }
ctx->lastError = rv;
return CKYSCARDERR;
}