From 05c3e1cddf6a74582d7f2ab65cb30a1d0f920f11 Mon Sep 17 00:00:00 2001 From: gongheng Date: Fri, 26 Jun 2026 17:24:57 +0800 Subject: [PATCH] chore: Remove unused code --Remove unused code that poses security risks --- application/utils.cpp | 28 ---------------------------- application/utils.h | 3 +-- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/application/utils.cpp b/application/utils.cpp index b99a1df1..bbd677b0 100644 --- a/application/utils.cpp +++ b/application/utils.cpp @@ -415,34 +415,6 @@ bool Utils::isCoredumpctlExist() return isCoredumpctlExist; } -QString Utils::getHomePath(const QString &userName) -{ - QString uName(""); - if (!userName.isEmpty()) - uName = userName; - else - uName = getCurrentUserName(); - - QString homePath = ""; - if (isValidUserName(uName)) { - QProcess *unlock = new QProcess; - unlock->start("sh", QStringList() << "-c" << QString("cat /etc/passwd | grep %1").arg(uName)); - unlock->waitForFinished(); - auto output = unlock->readAllStandardOutput(); - auto str = QString::fromUtf8(output); - homePath = str.mid(str.indexOf("::") + 2).split(":").first(); - } - - // 根据用户名获取家目录失败,默认采用QDir::homePath()作为homePath - QDir dir(homePath); - if (!dir.exists() || homePath.isEmpty()) - homePath = QDir::homePath(); - - qCDebug(logUtils) << "userName: " << uName << "homePath:" << homePath; - - return homePath; -} - QString Utils::appName(const QString &filePath) { QString ret; diff --git a/application/utils.h b/application/utils.h index 4e2bdfce..e1ab7b06 100755 --- a/application/utils.h +++ b/application/utils.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019 - 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2019 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -76,7 +76,6 @@ class Utils : public QObject static QString getCurrentUserName(); static bool isValidUserName(const QString &userName); static bool isCoredumpctlExist(); // is coredumpctl installed - static QString getHomePath(const QString &userName = ""); static QString appName(const QString &filePath); static void resetToNormalAuth(const QString &path); // 统计所有崩溃记录重复次数