From 28725494990cd4eb269dad09d5e2b5908047f546 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 4 Sep 2016 23:02:44 -0500 Subject: Add fallback to match udev cryptographic card reader name with PCSC vendor strings --- tdecore/tdehw/tdecryptographiccarddevice.cpp | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'tdecore/tdehw') diff --git a/tdecore/tdehw/tdecryptographiccarddevice.cpp b/tdecore/tdehw/tdecryptographiccarddevice.cpp index 98706befd..4e3e6f77d 100644 --- a/tdecore/tdehw/tdecryptographiccarddevice.cpp +++ b/tdecore/tdehw/tdecryptographiccarddevice.cpp @@ -146,8 +146,36 @@ void CryptoCardDeviceWatcher::run() { /* FIXME * Find a better / more reliable way to match the card low level device to the PCSC name */ + SCARDHANDLE hCard = 0; + DWORD dwActiveProtocol = 0; + DWORD cByte = 0; + TQString reader_vendor_name; + TQString reader_interface_type; + + ret = SCardConnect(m_cardContext, readers[i].ascii(), SCARD_SHARE_DIRECT, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, &hCard, &dwActiveProtocol); + if (ret == SCARD_S_SUCCESS) { + ret = SCardGetAttrib(hCard, SCARD_ATTR_VENDOR_NAME, NULL, &cByte); + if (ret == SCARD_S_SUCCESS) { + char* data = new char[cByte]; + ret = SCardGetAttrib(hCard, SCARD_ATTR_VENDOR_NAME, (LPBYTE)data, &cByte); + reader_vendor_name = data; + delete [] data; + } + ret = SCardGetAttrib(hCard, SCARD_ATTR_VENDOR_IFD_TYPE, NULL, &cByte); + if (ret == SCARD_S_SUCCESS) { + char* data = new char[cByte]; + ret = SCardGetAttrib(hCard, SCARD_ATTR_VENDOR_IFD_TYPE, (LPBYTE)data, &cByte); + reader_interface_type = data; + delete [] data; + } + SCardDisconnect(hCard, SCARD_LEAVE_CARD); + } + if (!readers[i].contains(cardDevice->friendlyName())) { - continue; + if (!cardDevice->friendlyName().contains(reader_vendor_name) || + ((reader_interface_type != "") && !cardDevice->friendlyName().contains(reader_vendor_name))) { + continue; + } } if (first_loop) { -- cgit v1.2.1