ukui-control-center/0006-fix-the-problem-that-the-new-user-in-the-control-panel-is-stuck.patch

55 lines
1.6 KiB
Diff

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