Fix the problem that the new user in the control panel is stuck

This commit is contained in:
huayadong 2022-03-11 16:55:16 +08:00
parent e6b921820e
commit c4459cb0da
2 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,54 @@
From d832b319220c7b02e4ce55a1980111b4170d31ec Mon Sep 17 00:00:00 2001
From: huayadong <huayadong@kylinos.cn>
Date: Fri, 11 Mar 2022 16:36:23 +0800
Subject: [PATCH] xxxxxxxxxxxxxxxxxxxxx
---
registeredQDbus/sysdbusregister.cpp | 29 ++++++++---------------------
1 file changed, 8 insertions(+), 21 deletions(-)
diff --git a/registeredQDbus/sysdbusregister.cpp b/registeredQDbus/sysdbusregister.cpp
index 4b7786f..4eecad5 100644
--- a/registeredQDbus/sysdbusregister.cpp
+++ b/registeredQDbus/sysdbusregister.cpp
@@ -162,29 +162,16 @@ void SysdbusRegister::setPasswdAging(int days, QString username) {
}
int SysdbusRegister::_changeOtherUserPasswd(QString username, QString pwd){
+ QProcess process;
+ QProcessEnvironment env;
+ env.insert("LC_ALL", "C");
- std::string str1 = username.toStdString();
- const char * user_name = str1.c_str();
+ process.setProcessEnvironment(env);
+ process.start("/usr/bin/passwd", QStringList() << QString(username));
+ process.write(QString("%1\n%2\n").arg(pwd).arg(pwd).toLatin1());
- std::string str2 = pwd.toStdString();
- const char * passwd = str2.c_str();
-
- QString output;
-
- char * cmd = g_strdup_printf("/usr/bin/changeotheruserpwd '%s' '%s'", user_name, passwd);
-
- FILE *stream;
- char buf[256];
-
- if ((stream = popen(cmd, "r" )) == NULL){
- return -1;
- }
-
- while(fgets(buf, 256, stream) != NULL){
- output = QString(buf).simplified();
- }
-
- pclose(stream);
+ process.closeWriteChannel();
+ process.waitForFinished();
return 1;
}
--
2.33.0

View File

@ -1,7 +1,7 @@
%define debug_package %{nil}
Name: ukui-control-center
Version: 3.0.4
Release: 7
Release: 8
Summary: utilities to configure the UKUI desktop
License: GPL-2+
URL: http://www.ukui.org
@ -11,6 +11,7 @@ Patch02: 0002-modify-area-info-display-error.patch
Patch03: 0003-fix-power-missing-issue.patch
Patch04: 0004-disable-the-str-of-password-check.patch
Patch05: 0005-Fix-the-problem-of-displaying-none-in-the-interface-version-information.patch
Patch06: 0006-fix-the-problem-that-the-new-user-in-the-control-panel-is-stuck.patch
BuildRequires: qt5-qtsvg-devel
BuildRequires: qt5-qtbase-devel
@ -113,6 +114,7 @@ Suggests: ukui-settings-daemon
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%build
qmake-qt5
@ -161,6 +163,9 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Fri Mar 11 2022 huayadong <huayadong@kylinos.cn> - 3.0.4-8
- add patch6: 0006-fix-the-problem-that-the-new-user-in-the-control-panel-is-stuck.patch
* Wed Mar 09 2022 huayadong <huayadong@kylinos.cn> - 3.0.4-7
- add patch5: 0004-Fix-the-problem-of-displaying-none-in-the-interface-version-information.patch