From 3c87a939f71fcb8ede1d24369852de6699a6a88f Mon Sep 17 00:00:00 2001 From: liuxinhao Date: Wed, 31 May 2023 16:36:45 +0800 Subject: [PATCH] fix(polkit-agent & locker): Remove the restriction on polkit-agent authentication errors,unset screensaver-dialog no fail delay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 去除polkit-agent认证错误限制,加入重新认证按钮。取消掉screensaver-dialog no-fail-delay。 --- ...nset-screensaver-dialog-no-fail-dela.patch | 53 +++ ...-Remove-the-restriction-on-polkit-ag.patch | 340 ++++++++++++++++++ kiran-session-guard.spec | 9 +- 3 files changed, 401 insertions(+), 1 deletion(-) create mode 100644 0001-fix-kiran-auth-unset-screensaver-dialog-no-fail-dela.patch create mode 100644 0002-fix-polkit-agent-Remove-the-restriction-on-polkit-ag.patch diff --git a/0001-fix-kiran-auth-unset-screensaver-dialog-no-fail-dela.patch b/0001-fix-kiran-auth-unset-screensaver-dialog-no-fail-dela.patch new file mode 100644 index 0000000..db9cfba --- /dev/null +++ b/0001-fix-kiran-auth-unset-screensaver-dialog-no-fail-dela.patch @@ -0,0 +1,53 @@ +From 5d0ba7b98f745b6090fd9c069bd9cc3d845c5421 Mon Sep 17 00:00:00 2001 +From: liuxinhao +Date: Mon, 29 May 2023 20:24:57 +0800 +Subject: [PATCH 1/2] fix(kiran auth): unset screensaver-dialog no fail delay +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 取消掉screensaver-dialog no-fail-delay,开启screensaver-dialog认证时的错误延时,显示出锁定后的提示消息 + +Closes #I7937W +--- + lib/login-frame/login-frame.cpp | 8 +++----- + src/screensaver-dialog/session-guard-checkpass/main.cpp | 4 +--- + 2 files changed, 4 insertions(+), 8 deletions(-) + +diff --git a/lib/login-frame/login-frame.cpp b/lib/login-frame/login-frame.cpp +index e80b057..8e49d84 100644 +--- a/lib/login-frame/login-frame.cpp ++++ b/lib/login-frame/login-frame.cpp +@@ -278,11 +278,9 @@ void LoginFrame::onShowPrmpt(const QString& text, PromptType type) + void LoginFrame::onAuthComplete(bool authRes) + { + KLOG_DEBUG() << "auth complete" << authRes; +- if (authRes) +- { +- authenticateComplete(authRes, m_authController->authenticationUser()); +- } +- else ++ authenticateComplete(authRes, m_authController->authenticationUser()); ++ ++ if( !authRes ) + { + #if 0 + if (m_prompted) +diff --git a/src/screensaver-dialog/session-guard-checkpass/main.cpp b/src/screensaver-dialog/session-guard-checkpass/main.cpp +index 92ec34d..9bad98d 100644 +--- a/src/screensaver-dialog/session-guard-checkpass/main.cpp ++++ b/src/screensaver-dialog/session-guard-checkpass/main.cpp +@@ -201,9 +201,7 @@ int main(int argc, char *argv[]) + KLOG_WARNING() << "failed to start pam:" << pam_strerror(pamh, ret); + return EXIT_FAILURE; + } +- +- pam_set_item(pamh, PAM_FAIL_DELAY, (void *)no_fail_delay); +- ++ + int authRes = PAM_SUCCESS; + authRes = pam_authenticate(pamh, 0); + const char *newUserName; +-- +2.33.0 + diff --git a/0002-fix-polkit-agent-Remove-the-restriction-on-polkit-ag.patch b/0002-fix-polkit-agent-Remove-the-restriction-on-polkit-ag.patch new file mode 100644 index 0000000..a9658fd --- /dev/null +++ b/0002-fix-polkit-agent-Remove-the-restriction-on-polkit-ag.patch @@ -0,0 +1,340 @@ +From 0a130f0034a77b5bb764a41f4832bcf224c9381f Mon Sep 17 00:00:00 2001 +From: liuxinhao +Date: Wed, 31 May 2023 14:29:18 +0800 +Subject: [PATCH 2/2] fix(polkit-agent): Remove the restriction on polkit-agent + authentication errors +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 去除polkit-agent认证错误限制,错误时需要点击左下重新认证按钮重新认证.适应部分认证流程不存在prompt消息 + +Closes #I7961L +--- + src/polkit-agent/dialog.cpp | 87 +++++++++++++++--------- + src/polkit-agent/dialog.h | 11 ++- + src/polkit-agent/dialog.ui | 27 +++++++- + translations/kiran-polkit-agent.zh_CN.ts | 25 +++++-- + 4 files changed, 110 insertions(+), 40 deletions(-) + +diff --git a/src/polkit-agent/dialog.cpp b/src/polkit-agent/dialog.cpp +index 16ca2aa..10fdbc5 100644 +--- a/src/polkit-agent/dialog.cpp ++++ b/src/polkit-agent/dialog.cpp +@@ -58,7 +58,7 @@ Dialog::Dialog(QWidget* parent) + : KiranTitlebarWindow(parent), + ui(new Ui::Dialog) + { +-ui->setupUi(getWindowContentWidget()); ++ ui->setupUi(getWindowContentWidget()); + resize(408, 290); + initUI(); + } +@@ -119,24 +119,44 @@ void Dialog::initUI() + layout()->setSizeConstraint(QLayout::SetFixedSize); + ui->label_tips->setWordWrap(true); + Kiran::StylePropertyHelper::setButtonType(ui->btn_ok, Kiran::BUTTON_Default); ++ Kiran::StylePropertyHelper::setButtonType(ui->btn_reauth, Kiran::BUTTON_Default); + ++ switchButtonLayout(BUTTON_LAYOUT_NORMAL); ++ + m_switcher = new AuthTypeSwitcher(EXPAND_DIRECTION_BOTTOM, 4, this); + m_switcher->setAdjustColorToTheme(true); + m_switcher->setFixedSize(QSize(42, 36)); + m_switcher->setVisible(false); + ui->layout_edit->addWidget(m_switcher); +- connect(m_switcher, &AuthTypeSwitcher::authTypeChanged, this, &Dialog::onCurrentAuthTypeChanged); ++ connect(m_switcher, &AuthTypeSwitcher::authTypeChanged, this, &Dialog::onSwitcherAuthTypeChanged); + + connect(ui->btn_cancel, &QPushButton::clicked, this, &Dialog::onCancelClicked); + connect(ui->btn_ok, &QPushButton::clicked, this, &Dialog::onOkClicked); ++ connect(ui->btn_reauth,&QPushButton::clicked,this,&Dialog::onReauthClicked); + connect(ui->edit->lineEdit(), &QLineEdit::returnPressed, this, &Dialog::onOkClicked); + connect(ui->combobox_user, QOverload::of(&QComboBox::currentIndexChanged), this, &Dialog::onCurrentUserChanged); + } + ++void Dialog::switchButtonLayout(ButtonLayout layout) ++{ ++ switch (layout) ++ { ++ case BUTTON_LAYOUT_NORMAL: ++ ui->btn_reauth->setVisible(false); ++ ui->btn_ok->setVisible(true); ++ break; ++ case BUTTON_LAYOUT_REAUTH: ++ ui->btn_reauth->setVisible(true); ++ ui->btn_ok->setVisible(false); ++ break; ++ default: ++ break; ++ } ++} ++ + void Dialog::startAuth(const QString& userName) + { + m_havePrompt = false; +- m_triesCount++; + + if (m_authController->inAuthentication()) + { +@@ -171,29 +191,19 @@ void Dialog::onOkClicked() + ui->btn_ok->setEnabled(false); + } + +-void Dialog::onCurrentUserChanged(int idx) ++void Dialog::onReauthClicked() + { + startAuth(ui->combobox_user->currentText()); + } + +-void Dialog::onCurrentAuthTypeChanged(KADAuthType authType) ++void Dialog::onCurrentUserChanged(int idx) + { +- QMap authTypeDesc = { +- {KAD_AUTH_TYPE_FINGERPRINT, tr("fingerprint auth")}, +- {KAD_AUTH_TYPE_FACE, tr("face auth")}, +- {KAD_AUTH_TYPE_FINGERVEIN, tr("fingervein auth")}}; ++ startAuth(ui->combobox_user->currentText()); ++} + +- ui->label_tips->setText(""); ++void Dialog::onSwitcherAuthTypeChanged(KADAuthType authType) ++{ + m_authController->switchAuthType(authType); +- ui->edit->setEnabled(false); +- ui->btn_ok->setEnabled(false); +- ui->edit->lineEdit()->clear(); +- ui->edit->lineEdit()->setPlaceholderText(""); +- +- if (authTypeDesc.contains(authType)) +- { +- ui->edit->lineEdit()->setPlaceholderText(authTypeDesc[authType]); +- } + } + + void Dialog::onNotifyAuthMode(KADAuthMode mode) +@@ -208,7 +218,29 @@ void Dialog::onSupportedAuthTypeChanged(QList authTypes) + + void Dialog::onNotifyAuthTypeChanged(KADAuthType authType) + { +- m_switcher->setCurrentAuthType(authType); ++ if( authType != m_switcher->getCurrentAuthType() ) ++ { ++ QSignalBlocker blocker(m_switcher); ++ m_switcher->setCurrentAuthType(authType); ++ } ++ ++ QMap authTypeDesc = { ++ {KAD_AUTH_TYPE_FINGERPRINT, tr("fingerprint auth")}, ++ {KAD_AUTH_TYPE_FACE, tr("face auth")}, ++ {KAD_AUTH_TYPE_FINGERVEIN, tr("fingervein auth")}, ++ {KAD_AUTH_TYPE_IRIS,tr("iris auth")}}; ++ ++ switchButtonLayout(BUTTON_LAYOUT_NORMAL); ++ ui->label_tips->setText(""); ++ ui->edit->setEnabled(false); ++ ui->btn_ok->setEnabled(false); ++ ui->edit->lineEdit()->clear(); ++ ui->edit->lineEdit()->setPlaceholderText(""); ++ ++ if (authTypeDesc.contains(authType)) ++ { ++ ui->edit->lineEdit()->setPlaceholderText(authTypeDesc[authType]); ++ } + } + + void Dialog::onAuthComplete(bool success) +@@ -219,21 +251,13 @@ void Dialog::onAuthComplete(bool success) + this->close(); + return; + } +- +- if (m_havePrompt && (m_triesCount < MAX_ERROR_COUNT)) +- { +- onAuthShowMessage("Authentication error, please authenticate again.", MessageTypeInfo); +- startAuth(ui->combobox_user->currentText()); +- } + else + { +- if (m_triesCount == MAX_ERROR_COUNT) +- { +- onAuthShowMessage("Authentication error", MessageTypeError); +- } +- ui->btn_ok->setEnabled(false); ++ onAuthShowMessage("Authentication error", MessageTypeError); ++ + ui->edit->lineEdit()->clear(); + ui->edit->setEnabled(false); ++ switchButtonLayout(BUTTON_LAYOUT_REAUTH); + } + } + +@@ -256,7 +280,6 @@ void Dialog::onAuthShowMessage(const QString& text, MessageType msgType) + + ui->label_tips->setText(tips); + } +- + } // namespace PolkitAgent + } // namespace SessionGuard + } // namespace Kiran +\ No newline at end of file +diff --git a/src/polkit-agent/dialog.h b/src/polkit-agent/dialog.h +index fe56251..7fbb85d 100644 +--- a/src/polkit-agent/dialog.h ++++ b/src/polkit-agent/dialog.h +@@ -64,6 +64,11 @@ public: + class Dialog : public KiranTitlebarWindow + { + Q_OBJECT ++ enum ButtonLayout ++ { ++ BUTTON_LAYOUT_NORMAL, ++ BUTTON_LAYOUT_REAUTH ++ }; + public: + explicit Dialog(QWidget* parent = nullptr); + ~Dialog(); +@@ -77,14 +82,16 @@ signals: + + private: + void initUI(); ++ void switchButtonLayout(ButtonLayout layout); + bool setAuthInfo(const AuthInfo& authInfo); + void startAuth(const QString& userName); + + private slots: + void onCancelClicked(); + void onOkClicked(); ++ void onReauthClicked(); + void onCurrentUserChanged(int idx); +- void onCurrentAuthTypeChanged(KADAuthType authType); ++ void onSwitcherAuthTypeChanged(KADAuthType authType); + + void onNotifyAuthMode(KADAuthMode mode); + void onSupportedAuthTypeChanged(QList authTypes); +@@ -102,7 +109,7 @@ private: + AuthController* m_authController; + AuthTypeSwitcher* m_switcher; + bool m_havePrompt = false; +- int m_triesCount = 0; ++ ButtonLayout m_buttonLayout = BUTTON_LAYOUT_NORMAL; + }; + } // namespace PolkitAgent + } // namespace SessionGuard +diff --git a/src/polkit-agent/dialog.ui b/src/polkit-agent/dialog.ui +index 74120eb..b1d4994 100644 +--- a/src/polkit-agent/dialog.ui ++++ b/src/polkit-agent/dialog.ui +@@ -6,7 +6,7 @@ + + 0 + 0 +- 407 ++ 410 + 234 + + +@@ -214,6 +214,31 @@ + + + ++ ++ ++ ++ ++ 0 ++ 0 ++ ++ ++ ++ ++ 110 ++ 40 ++ ++ ++ ++ ++ 110 ++ 40 ++ ++ ++ ++ Recertification ++ ++ ++ + + + +diff --git a/translations/kiran-polkit-agent.zh_CN.ts b/translations/kiran-polkit-agent.zh_CN.ts +index 97ce7f8..ae75cc2 100644 +--- a/translations/kiran-polkit-agent.zh_CN.ts ++++ b/translations/kiran-polkit-agent.zh_CN.ts +@@ -41,11 +41,16 @@ + + + ++ Recertification ++ 重新认证 ++ ++ ++ + Ok + 确认 + + +- ++ + Cancel + 取消 + +@@ -69,7 +74,7 @@ + + Kiran::SessionGuard::AuthController + +- ++ + Failed to authenticate + 认证失败 + +@@ -96,6 +101,16 @@ + finger vein auth + 指静脉认证 + ++ ++ ++ iris auth ++ 虹膜认证 ++ ++ ++ ++ ukey auth ++ UKey认证 ++ + + + Kiran::SessionGuard::PolkitAgent::Dialog +@@ -105,17 +120,17 @@ + 认证 + + +- ++ + fingerprint auth + 指纹认证 + + +- ++ + face auth + 人脸认证 + + +- ++ + fingervein auth + 指静脉认证 + +-- +2.33.0 + diff --git a/kiran-session-guard.spec b/kiran-session-guard.spec index e505c97..51529c7 100644 --- a/kiran-session-guard.spec +++ b/kiran-session-guard.spec @@ -1,12 +1,15 @@ Name: kiran-session-guard Version: 2.5.1 -Release: 1 +Release: 2 Summary: Kiran desktop environment login and lock screen dialog Summary(zh_CN): Kiran桌面环境登录和解锁框 License: MulanPSL-2.0 Source0: %{name}-%{version}.tar.gz +Patch0001: 0001-fix-kiran-auth-unset-screensaver-dialog-no-fail-dela.patch +Patch0002: 0002-fix-polkit-agent-Remove-the-restriction-on-polkit-ag.patch + %define SHOW_VIRTUAL_KEYBOARD 0 BuildRequires: cmake @@ -143,6 +146,10 @@ gtk-update-icon-cache -f /usr/share/icons/hicolor/ rm -rf %{buildroot} %changelog +* Wed May 31 2023 liuxinhao - 2.5.1-2 +- KYOS-B: unset screensaver-dialog no fail delay(#I7937W) +- KYOS-B: Remove the restriction on polkit-agent authentication errors(#I7961L) + * Wed May 24 2023 liuxinhao - 2.5.1-1 - KYOS-F: If the authentication fails, the re-authentication button is displayed.(#69229) - KYOS-B: Fixed an issue caused by selecting default desktop session(#69204,#69220) -- Gitee