代码拉取完成,页面将自动刷新
同步操作将从 src-anolis-dde/dde-control-center 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 6c4050e695babbe68b321e5669be280fe6c3b0c6 Mon Sep 17 00:00:00 2001
From: xingwei-liu <liuxingwei@uniontech.com>
Date: Wed, 5 Jan 2022 09:27:08 +0800
Subject: [PATCH] add password reminder
---
src/frame/modules/accounts/accountsworker.cpp | 80 ++++---------------
.../modules/accounts/modifypasswdpage.cpp | 6 +-
2 files changed, 18 insertions(+), 68 deletions(-)
diff --git a/src/frame/modules/accounts/accountsworker.cpp b/src/frame/modules/accounts/accountsworker.cpp
index cf80a16..7f11f21 100644
--- a/src/frame/modules/accounts/accountsworker.cpp
+++ b/src/frame/modules/accounts/accountsworker.cpp
@@ -53,65 +53,6 @@ const QString DisplayManagerService("org.freedesktop.DisplayManager");
const QString AutoLoginVisable = "auto-login-visable";
const QString NoPasswordVisable = "nopasswd-login-visable";
-const QString ModifyPassword =
-R"(#!/usr/bin/expect
-
-# oldpassword: the current password
-# userpass: the new password
-# repeatpass: repeat the new password
-set oldpassword [lindex $argv 0]
-set userpass [lindex $argv 1]
-set repeatpass [lindex $argv 2]
-
-# spawn the passwd command process
-spawn passwd
-
-# Verify the 'Current password'
-expect "Current password: "
-send -- "$oldpassword\r"
-
-# Type the 'New password'
-expect "New password:"
-send -- "$userpass\r"
-
-# current password verify
-send_user "\rpassword right\r"
-
-# Verify the 'Retype password'
-expect "Retype*"
-send -- "$repeatpass\r"
-
-# Type the 'New password'
-expect "New password:"
-send -- "$userpass\r"
-
-# Verify the 'Retype password'
-expect "Retype*"
-send -- "$repeatpass\r"
-
-expect eof
-)";
-
-const QString ModifyNoPassword =
-R"(#!/usr/bin/expect
-
-# userpass: the new password
-# repeatpass: repeat the new password
-set userpass [lindex $argv 0]
-set repeatpass [lindex $argv 1]
-
-# spawn the passwd command process
-spawn passwd
-
-# Type the 'New password'
-expect "New password:"
-send -- "$userpass\r"
-
-# Verify the 'Retype password'
-expect "Retype*"
-send -- "$repeatpass\r"
-expect eof
-)";
AccountsWorker::AccountsWorker(UserModel *userList, QObject *parent)
: QObject(parent)
@@ -386,16 +327,23 @@ void AccountsWorker::setPassword(User *user, const QString &oldpwd, const QStrin
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("LC_ALL", "C");
process.setProcessEnvironment(env);
+ process.setProcessChannelMode(QProcess::MergedChannels);
- QString cmd = user->passwordStatus() == NO_PASSWORD ? ModifyNoPassword : ModifyPassword;
+ process.start("/bin/bash", QStringList() << "-c" << QString("passwd"));
+ if (user->passwordStatus() == NO_PASSWORD) {
+ process.write(QString("%1\n%2\n").arg(passwd).arg(repeatPasswd).toLatin1());
+ }else {
+ process.write(QString("%1\n%2\n%3").arg(oldpwd).arg(passwd).arg(repeatPasswd).toLatin1());
+ }
+ //QString cmd = user->passwordStatus() == NO_PASSWORD ? ModifyNoPassword : ModifyPassword;
- QStringList args = QStringList() << "-f" << "-";
- if (user->passwordStatus() != NO_PASSWORD) args.append(oldpwd);
- args.append(passwd);
- args.append(repeatPasswd);
+ //QStringList args = QStringList() << "-f" << "-";
+ //if (user->passwordStatus() != NO_PASSWORD) args.append(oldpwd);
+ //args.append(passwd);
+ //args.append(repeatPasswd);
- process.start("/bin/expect", args);
- process.write(cmd.toLatin1());
+ //process.start("/bin/expect", args);
+ //process.write(cmd.toLatin1());
process.closeWriteChannel();
process.waitForFinished();
diff --git a/src/frame/window/modules/accounts/modifypasswdpage.cpp b/src/frame/window/modules/accounts/modifypasswdpage.cpp
index 9b2137f..e1e63cb 100644
--- a/src/frame/window/modules/accounts/modifypasswdpage.cpp
+++ b/src/frame/window/modules/accounts/modifypasswdpage.cpp
@@ -166,8 +166,10 @@ void ModifyPasswdPage::onPasswordChangeFinished(const int exitCode, const QStrin
Q_UNUSED(exitCode)
PwqualityManager::ERROR_TYPE error = PwqualityManager::instance()->verifyPassword(m_curUser->name(),
m_newPasswordEdit->lineEdit()->text());
- if (errorTxt.contains("password unchanged")) {
- if (!errorTxt.contains("password right", Qt::CaseInsensitive)) {
+ //if (errorTxt.contains("password unchanged")) {
+ if (exitCode != 0) {
+ if (errorTxt.startsWith("Current password: Current Password: passwd:", Qt::CaseInsensitive)) {
+ //if (!errorTxt.contains("password right", Qt::CaseInsensitive)) {
m_oldPasswordEdit->setAlert(true);
m_oldPasswordEdit->showAlertMessage(tr("Wrong password"));
return;
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。