!17 修复deviceSerialNumber为空时,从数据库获取不到feature的问题
From: @luoqing_kylinsec Reviewed-by: @liubuguiii Signed-off-by: @liubuguiii
This commit is contained in:
commit
f8803042a9
@ -0,0 +1,78 @@
|
||||
From bdb3eb90ad2ab0f08365b71fefb33c76b96c4359 Mon Sep 17 00:00:00 2001
|
||||
From: luoqing <luoqing@kylinsec.com.cn>
|
||||
Date: Fri, 2 Jun 2023 19:09:11 +0800
|
||||
Subject: [PATCH] fix(feature-db):Fix the issue of not obtaining features from
|
||||
the database when deviceSerialNumber is empty
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
- 修复deviceSerialNumber为空时,从数据库获取不到feature的问题
|
||||
---
|
||||
src/device/fingerprint/fp-zk-device.cpp | 1 +
|
||||
src/feature-db.cpp | 18 +++++++++++++++---
|
||||
2 files changed, 16 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/device/fingerprint/fp-zk-device.cpp b/src/device/fingerprint/fp-zk-device.cpp
|
||||
index 4d8abc0..16ceb37 100644
|
||||
--- a/src/device/fingerprint/fp-zk-device.cpp
|
||||
+++ b/src/device/fingerprint/fp-zk-device.cpp
|
||||
@@ -398,6 +398,7 @@ QString FPZKDevice::identifyFeature(QByteArray fpTemplate, QStringList featureID
|
||||
|
||||
if (saveList.count() == 0)
|
||||
{
|
||||
+ KLOG_DEBUG() << "no found feature";
|
||||
return QString();
|
||||
}
|
||||
|
||||
diff --git a/src/feature-db.cpp b/src/feature-db.cpp
|
||||
index ee0a4bd..a8aa883 100644
|
||||
--- a/src/feature-db.cpp
|
||||
+++ b/src/feature-db.cpp
|
||||
@@ -92,7 +92,7 @@ bool FeatureDB::addFeature(const QString &featureID, QByteArray feature, DeviceI
|
||||
query.bindValue(":idVendor", deviceInfo.idVendor);
|
||||
query.bindValue(":idProduct", deviceInfo.idProduct);
|
||||
query.bindValue(":deviceType", (int)deviceType);
|
||||
- query.bindValue(":deviceSerialNumber", deviceSerialNumber);
|
||||
+ query.bindValue(":deviceSerialNumber", deviceSerialNumber.isEmpty() ? QVariant(QVariant::String) : deviceSerialNumber);
|
||||
return query.exec();
|
||||
}
|
||||
|
||||
@@ -121,12 +121,19 @@ QByteArray FeatureDB::getFeature(const QString &featureID)
|
||||
QList<QByteArray> FeatureDB::getFeatures(const QString &idVendor, const QString &idProduct, DeviceType deviceType, const QString &deviceSerialNumber)
|
||||
{
|
||||
QSqlQuery query(m_database);
|
||||
- query.prepare("SELECT feature FROM feature WHERE idVendor = :Vid AND idProduct = :Pid AND deviceType = :devType AND deviceSerialNumber = :serialNumber");
|
||||
+ QString sql = "SELECT feature FROM feature WHERE idVendor = :Vid AND idProduct = :Pid AND deviceType = :devType";
|
||||
+ if (!deviceSerialNumber.isEmpty())
|
||||
+ {
|
||||
+ sql.append(" AND deviceSerialNumber = :serialNumber");
|
||||
+ }
|
||||
+
|
||||
+ query.prepare(sql);
|
||||
query.bindValue(":Vid", idVendor);
|
||||
query.bindValue(":Pid", idProduct);
|
||||
query.bindValue(":devType", (int)deviceType);
|
||||
query.bindValue(":serialNumber", deviceSerialNumber);
|
||||
query.exec();
|
||||
+
|
||||
QByteArrayList featuresList;
|
||||
while (query.next())
|
||||
{
|
||||
@@ -153,7 +160,12 @@ QList<QByteArray> FeatureDB::getAllFeatures()
|
||||
QStringList FeatureDB::getFeatureIDs(const QString &idVendor, const QString &idProduct, DeviceType deviceType, const QString &deviceSerialNumber)
|
||||
{
|
||||
QSqlQuery query(m_database);
|
||||
- query.prepare("SELECT featureID FROM feature WHERE idVendor = :Vid AND idProduct = :Pid AND deviceType = :devType AND deviceSerialNumber = :serialNumber");
|
||||
+ QString sql = "SELECT featureID FROM feature WHERE idVendor = :Vid AND idProduct = :Pid AND deviceType = :devType";
|
||||
+ if (!deviceSerialNumber.isEmpty())
|
||||
+ {
|
||||
+ sql.append(" AND deviceSerialNumber = :serialNumber");
|
||||
+ }
|
||||
+
|
||||
query.bindValue(":Vid", idVendor);
|
||||
query.bindValue(":Pid", idProduct);
|
||||
query.bindValue(":devType", (int)deviceType);
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Name: kiran-authentication-devices
|
||||
|
||||
Version: 2.5.1
|
||||
Release: 3
|
||||
Release: 4
|
||||
Summary: Kiran Authentication Devices
|
||||
|
||||
License: MulanPSL-2.0
|
||||
@ -9,6 +9,7 @@ Source0: %{name}-%{version}.tar.gz
|
||||
|
||||
Patch0001: 0001-fix-mf-iristar-driver-Fix-compilation-issues-with-st.patch
|
||||
Patch0002: 0001-fix-ukey-Fix-the-issue-where-only-one-ukey-can-be-bo.patch
|
||||
Patch0003: 0001-fix-feature-db-Fix-the-issue-of-not-obtaining-featur.patch
|
||||
|
||||
BuildRequires: cmake
|
||||
BuildRequires: gcc-c++
|
||||
@ -66,6 +67,9 @@ systemctl enable kiran-authentication-devices.service
|
||||
rm -rf ${buildroot}
|
||||
|
||||
%changelog
|
||||
* Fri Jun 2 2023 luoqing <luoqing@kylinsec.com.cn> - 2.5.1-4
|
||||
- KYOS-F: Fix the issue of not obtaining features from the database when deviceSerialNumber is empty
|
||||
|
||||
* Fri Jun 2 2023 luoqing <luoqing@kylinsec.com.cn> - 2.5.1-3
|
||||
- KYOS-F: Fix the issue where only one ukey can be bound to a device, some self-test bugs.(#I78P3F)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user