!43 [sync] PR-41: 在kiranUI-2.5中适配qt5.10以下的版本
From: @openeuler-sync-bot Reviewed-by: @liubuguiii Signed-off-by: @liubuguiii
This commit is contained in:
commit
8cbdd0c802
204
0012-fix-kiran-authentication-service-fix-for-versions-ea.patch
Normal file
204
0012-fix-kiran-authentication-service-fix-for-versions-ea.patch
Normal file
@ -0,0 +1,204 @@
|
||||
From 3b847f53c73bf1695a9fe81420c7faa480fa3357 Mon Sep 17 00:00:00 2001
|
||||
From: niko_yhc <yinhongchang@kylinsec.com.cn>
|
||||
Date: Mon, 11 Sep 2023 08:50:19 +0800
|
||||
Subject: [PATCH] fix(kiran-authentication-service):fix for versions earlier
|
||||
than qt5.10 in kiranUI-2.5
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
- 在kiranUI-2.5中适配qt5.10以下的版本
|
||||
|
||||
Closes:#15019
|
||||
---
|
||||
CMakeLists.txt | 6 +++++-
|
||||
src/daemon/auth-manager.cpp | 5 +++++
|
||||
src/daemon/auth-manager.h | 4 ++++
|
||||
src/daemon/device/device-adaptor-factory.cpp | 10 +++++-----
|
||||
src/daemon/device/device-adaptor.cpp | 12 ++++++------
|
||||
src/pam/authentication-graphical.cpp | 20 ++++++++++++++++++++
|
||||
6 files changed, 45 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 22e5ac2..a77f4b3 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -22,7 +22,11 @@ find_package(Qt5 COMPONENTS Core DBus LinguistTools)
|
||||
pkg_search_module(KLOG_QT5 REQUIRED klog-qt5)
|
||||
pkg_search_module(SYSTEMD REQUIRED systemd)
|
||||
pkg_search_module(KIRAN_CC_DAEMON REQUIRED kiran-cc-daemon)
|
||||
-pkg_search_module(PAM REQUIRED pam)
|
||||
+pkg_search_module(PAM QUIET pam)
|
||||
+if(NOT DEFINED ${PAM_FOUND})
|
||||
+ set(PAM_INCLUDE_DIRS /usr/include/security)
|
||||
+ set(PAM_LIBRARIES pam)
|
||||
+endif()
|
||||
pkg_search_module(LIBSYSTEMD REQUIRED libsystemd)
|
||||
|
||||
configure_file(config.h.in ${PROJECT_BINARY_DIR}/config.h)
|
||||
diff --git a/src/daemon/auth-manager.cpp b/src/daemon/auth-manager.cpp
|
||||
index 3d7aaf0..a030897 100644
|
||||
--- a/src/daemon/auth-manager.cpp
|
||||
+++ b/src/daemon/auth-manager.cpp
|
||||
@@ -276,7 +276,12 @@ int32_t AuthManager::generateSessionID()
|
||||
// 最多生成10次,超过次数则返回失败
|
||||
for (int i = 0; i <= 10; ++i)
|
||||
{
|
||||
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
auto sessionID = this->m_randomGenerator.bounded(1, MAX_SESSION_ID);
|
||||
+#else
|
||||
+ qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
|
||||
+ auto sessionID = qrand() % MAX_SESSION_ID + 1;
|
||||
+#endif
|
||||
auto session = this->m_sessions.value(sessionID, nullptr);
|
||||
// KLOG_DEBUG() << "session: " << session << ", sessionID: " << sessionID;
|
||||
RETURN_VAL_IF_TRUE(session == nullptr, sessionID);
|
||||
diff --git a/src/daemon/auth-manager.h b/src/daemon/auth-manager.h
|
||||
index e707e0b..b6f2446 100644
|
||||
--- a/src/daemon/auth-manager.h
|
||||
+++ b/src/daemon/auth-manager.h
|
||||
@@ -16,7 +16,9 @@
|
||||
#include <QDBusContext>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QList>
|
||||
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
#include <QRandomGenerator>
|
||||
+#endif
|
||||
#include "kas-authentication-i.h"
|
||||
|
||||
class AuthManagerAdaptor;
|
||||
@@ -118,7 +120,9 @@ private:
|
||||
|
||||
// <会话ID,会话>
|
||||
QMap<int32_t, Session *> m_sessions;
|
||||
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
QRandomGenerator m_randomGenerator;
|
||||
+#endif
|
||||
QDBusServiceWatcher *m_serviceWatcher;
|
||||
};
|
||||
|
||||
diff --git a/src/daemon/device/device-adaptor-factory.cpp b/src/daemon/device/device-adaptor-factory.cpp
|
||||
index 531e0d9..590214c 100644
|
||||
--- a/src/daemon/device/device-adaptor-factory.cpp
|
||||
+++ b/src/daemon/device/device-adaptor-factory.cpp
|
||||
@@ -206,8 +206,8 @@ void DeviceAdaptorFactory::onAuthDeviceManagerLost(const QString &service)
|
||||
// 设备管理服务消失,认证设备无效,应清理所有无效的设备及其请求
|
||||
for (auto iter = m_devices.begin(); iter != m_devices.end();)
|
||||
{
|
||||
- KLOG_DEBUG() << "auth device manager lost,remove device:" << iter->get()->getDeviceID();
|
||||
- iter->get()->removeAllRequest();
|
||||
+ KLOG_DEBUG() << "auth device manager lost,remove device:" << iter.value().data()->getDeviceID();
|
||||
+ iter.value().data()->removeAllRequest();
|
||||
iter = m_devices.erase(iter);
|
||||
}
|
||||
}
|
||||
@@ -217,10 +217,10 @@ void DeviceAdaptorFactory::onDeviceDeleted(int deviceType, const QString &device
|
||||
// 认证设备拔出,认证设备变成无效,清理该设备下请求,从缓存中删除该设备
|
||||
for (auto iter = m_devices.begin(); iter != m_devices.end(); iter++)
|
||||
{
|
||||
- if (iter->get()->getDeviceID() == deviceID)
|
||||
+ if (iter.value().data()->getDeviceID() == deviceID)
|
||||
{
|
||||
- KLOG_DEBUG() << "auth device deleted,remove device:" << iter->get()->getDeviceID();
|
||||
- iter->get()->removeAllRequest();
|
||||
+ KLOG_DEBUG() << "auth device deleted,remove device:" << iter.value().data()->getDeviceID();
|
||||
+ iter.value().data()->removeAllRequest();
|
||||
m_devices.erase(iter);
|
||||
break;
|
||||
}
|
||||
diff --git a/src/daemon/device/device-adaptor.cpp b/src/daemon/device/device-adaptor.cpp
|
||||
index 369554d..cef646f 100644
|
||||
--- a/src/daemon/device/device-adaptor.cpp
|
||||
+++ b/src/daemon/device/device-adaptor.cpp
|
||||
@@ -41,7 +41,7 @@ DeviceAdaptor::DeviceAdaptor(QSharedPointer<AuthDeviceProxy> dbusDeviceProxy)
|
||||
connect(&m_deviceOccupyTimer,&QTimer::timeout,this,&DeviceAdaptor::onDeviceOccupyTimeout);
|
||||
|
||||
auto defaultSeat = Login1SeatProxy::getDefault();
|
||||
- connect(defaultSeat.get(), SIGNAL(activeSessionChanged(const Login1SessionItem &)), this, SLOT(onActiveSessionChanged(const Login1SessionItem &)));
|
||||
+ connect(defaultSeat.data(), SIGNAL(activeSessionChanged(const Login1SessionItem &)), this, SLOT(onActiveSessionChanged(const Login1SessionItem &)));
|
||||
|
||||
this->updateDBusDeviceProxy(dbusDeviceProxy);
|
||||
}
|
||||
@@ -76,8 +76,8 @@ void DeviceAdaptor::removeAllRequest()
|
||||
// 清空/结束所有认证,不再参与调度
|
||||
for (auto iter = this->m_requests.begin(); iter != this->m_requests.end();)
|
||||
{
|
||||
- iter->get()->source->cancel();
|
||||
- iter->get()->source->end();
|
||||
+ iter.value().data()->source->cancel();
|
||||
+ iter.value().data()->source->end();
|
||||
iter = this->m_requests.erase(iter);
|
||||
}
|
||||
}
|
||||
@@ -107,8 +107,8 @@ void DeviceAdaptor::updateDBusDeviceProxy(QSharedPointer<AuthDeviceProxy> dbusDe
|
||||
|
||||
this->interruptRequest();
|
||||
|
||||
- connect(this->m_dbusDeviceProxy.get(), &AuthDeviceProxy::EnrollStatus, this, &DeviceAdaptor::onEnrollStatus);
|
||||
- connect(this->m_dbusDeviceProxy.get(), &AuthDeviceProxy::IdentifyStatus, this, &DeviceAdaptor::onIdentifyStatus);
|
||||
+ connect(this->m_dbusDeviceProxy.data(), &AuthDeviceProxy::EnrollStatus, this, &DeviceAdaptor::onEnrollStatus);
|
||||
+ connect(this->m_dbusDeviceProxy.data(), &AuthDeviceProxy::IdentifyStatus, this, &DeviceAdaptor::onIdentifyStatus);
|
||||
|
||||
DEVICE_DEBUG() << "update auth device finished";
|
||||
this->schedule();
|
||||
@@ -134,7 +134,7 @@ void DeviceAdaptor::wakeRequest(QSharedPointer<DeviceRequest> request)
|
||||
{
|
||||
RETURN_IF_FALSE(request);
|
||||
// 请求未变化,直接返回
|
||||
- RETURN_IF_TRUE(this->m_currentRequest && this->m_currentRequest.get() == request.get());
|
||||
+ RETURN_IF_TRUE(this->m_currentRequest && this->m_currentRequest.data() == request.data());
|
||||
// 中断当前的请求
|
||||
this->interruptRequest();
|
||||
|
||||
diff --git a/src/pam/authentication-graphical.cpp b/src/pam/authentication-graphical.cpp
|
||||
index 2f104ac..4a31b77 100644
|
||||
--- a/src/pam/authentication-graphical.cpp
|
||||
+++ b/src/pam/authentication-graphical.cpp
|
||||
@@ -52,12 +52,22 @@ bool AuthenticationGraphical::requestLoginUserSwitchable()
|
||||
// 请求失败的情况下使用默认值
|
||||
if (retval != PAM_SUCCESS)
|
||||
{
|
||||
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
auto errorMsg = jsonReqDoc[KAP_PJK_KEY_HEAD][KAP_PJK_KEY_ERROR].toString();
|
||||
+#else
|
||||
+ QJsonValue val = jsonReqDoc.object()[KAP_PJK_KEY_HEAD];
|
||||
+ auto errorMsg = val.toObject()[KAP_PJK_KEY_ERROR].toString();
|
||||
+#endif
|
||||
this->m_pamHandle->syslog(LOG_WARNING, QString("Request login user switchable failed: %1").arg(errorMsg));
|
||||
return false;
|
||||
}
|
||||
|
||||
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
return jsonRspDoc[KAP_PJK_KEY_BODY][KAP_PJK_KEY_LOGIN_USER_SWITCHABLE].toBool();
|
||||
+#else
|
||||
+ QJsonValue val = jsonRspDoc.object()[KAP_PJK_KEY_BODY];
|
||||
+ return val.toObject()[KAP_PJK_KEY_LOGIN_USER_SWITCHABLE].toBool();
|
||||
+#endif
|
||||
}
|
||||
|
||||
void AuthenticationGraphical::notifySupportAuthType()
|
||||
@@ -90,11 +100,21 @@ int32_t AuthenticationGraphical::requestAuthType()
|
||||
// 请求失败的情况下使用默认认证类型
|
||||
if (retval != PAM_SUCCESS)
|
||||
{
|
||||
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
auto errorMsg = jsonReqDoc[KAP_PJK_KEY_HEAD][KAP_PJK_KEY_ERROR].toString();
|
||||
+#else
|
||||
+ QJsonValue val = jsonReqDoc.object()[KAP_PJK_KEY_HEAD];
|
||||
+ auto errorMsg = val.toObject()[KAP_PJK_KEY_ERROR].toString();
|
||||
+#endif
|
||||
this->m_pamHandle->syslog(LOG_WARNING, QString("Request auth type failed: %1").arg(errorMsg));
|
||||
return KADAuthType::KAD_AUTH_TYPE_NONE;
|
||||
}
|
||||
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
return jsonRspDoc[KAP_PJK_KEY_BODY][KAP_PJK_KEY_AUTH_TYPE].toInt();
|
||||
+#else
|
||||
+ QJsonValue val = jsonRspDoc.object()[KAP_PJK_KEY_BODY];
|
||||
+ return val.toObject()[KAP_PJK_KEY_AUTH_TYPE].toInt();
|
||||
+#endif
|
||||
}
|
||||
|
||||
void AuthenticationGraphical::notifyAuthType(int authType)
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: kiran-authentication-service
|
||||
Version: 2.5.1
|
||||
Release: 6
|
||||
Release: 7
|
||||
Summary: Kiran Desktop kiran authentication service
|
||||
License: MulanPSL-2.0
|
||||
URL: http://www.kylinsec.com.cn
|
||||
@ -18,6 +18,8 @@ Patch0008: 0008-fix-default-device-Update-the-logic-of-the-default-a.patch
|
||||
Patch0009: 0009-fix-multi-factor-multi-factor-no-jump-login.patch
|
||||
Patch0010: 0010-fix-multi-channel-auth-If-the-authentication-fails-t.patch
|
||||
Patch0011: 0011-feat-auth-error-Subdivide-the-cause-of-the-error-and.patch
|
||||
Patch0012: 0012-fix-kiran-authentication-service-fix-for-versions-ea.patch
|
||||
|
||||
|
||||
BuildRequires: systemd
|
||||
BuildRequires: systemd-devel
|
||||
@ -93,6 +95,9 @@ systemctl enable kiran-authentication-daemon.service
|
||||
%{_includedir}/kiran-authentication-service/kas-authentication-i.h
|
||||
|
||||
%changelog
|
||||
* Mon Sep 11 2023 yinhongchang <yinhongchang@kylinsec.com.cn> - 2.5.1-7
|
||||
- KYOS-F: fix for versions earlier than qt5.10 in kiranUI-2.5(#15019)
|
||||
|
||||
* Thu Jun 15 2023 liuxinhao <liuxinhao@kylinsec.com.cn> - 2.5.1-6
|
||||
- KYOS-B: Subdivide the cause of the error and determine whether to record the error according to the cause and mode(#I7DCKL)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user