summaryrefslogtreecommitdiffstats
path: root/tdecore
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2016-09-04 23:02:44 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2016-09-04 23:02:44 -0500
commit28725494990cd4eb269dad09d5e2b5908047f546 (patch)
treee1da5a2e0f93a289190153a503c5fccff026045c /tdecore
parent0d8345e6f7f2402d3ee88c0eb3d89e0e839bc5b5 (diff)
downloadtdelibs-28725494990cd4eb269dad09d5e2b5908047f546.tar.gz
tdelibs-28725494990cd4eb269dad09d5e2b5908047f546.zip
Add fallback to match udev cryptographic card reader name with PCSC vendor strings
Diffstat (limited to 'tdecore')
-rw-r--r--tdecore/tdehw/tdecryptographiccarddevice.cpp30
1 files changed, 29 insertions, 1 deletions
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) {