From 12cd224f423ccae5c22c4efb1396700d78a896f9 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Fri, 19 Jul 2024 15:20:11 +0200 Subject: [PATCH] Hardware keys: Fix PCSC daemon recovery on Linux --- src/keys/drivers/YubiKeyInterfacePCSC.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/keys/drivers/YubiKeyInterfacePCSC.cpp b/src/keys/drivers/YubiKeyInterfacePCSC.cpp index 0d25ac434..708a0c92e 100644 --- a/src/keys/drivers/YubiKeyInterfacePCSC.cpp +++ b/src/keys/drivers/YubiKeyInterfacePCSC.cpp @@ -70,7 +70,8 @@ namespace rv = SCardListReaders(context, nullptr, nullptr, &dwReaders); // On windows, USB hot-plugging causes the underlying API server to die // So on every USB unplug event, the API context has to be recreated - if (rv == SCARD_E_SERVICE_STOPPED) { + // On Linux, restarting the pcsc daemon causes the API server to die as well + if (rv == SCARD_E_SERVICE_STOPPED || rv == SCARD_E_NO_SERVICE) { // Dont care if the release works since the handle might be broken SCardReleaseContext(context); rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, nullptr, nullptr, &context);