diff --git a/0006-fix-get-home-path-method.patch b/0006-fix-get-home-path-method.patch new file mode 100644 index 0000000000000000000000000000000000000000..4e27a70ee9f7a0892eafbb1ab3f26d7509b2a0ed --- /dev/null +++ b/0006-fix-get-home-path-method.patch @@ -0,0 +1,44 @@ +diff --git a/nfs-logtools-1.0.0/getcontent.cpp b/nfs-logtools-1.0.0/getcontent.cpp +index 4263925..127b068 100644 +--- a/nfs-logtools-1.0.0/getcontent.cpp ++++ b/nfs-logtools-1.0.0/getcontent.cpp +@@ -9,7 +9,7 @@ QString GetContent::getHomePath() + QProcess *execCmd = new QProcess(); + QStringList params; + QStringList getUserName; +- QStringList curHome; ++ QString curHome; + QString curUserByWho = ""; + QString curUserByLast = ""; + QString curUser = ""; +@@ -44,7 +44,7 @@ QString GetContent::getHomePath() + tmpLine.clear(); + } + } +- ++ //取第一个非root的用户 + int i = 0; + do { + if (contentList[i].contains("root", Qt::CaseInsensitive)) { +@@ -61,15 +61,14 @@ QString GetContent::getHomePath() + else { + return "/root"; + } +- +- execCmd->start("bash", QStringList() << "-c" << "cat /etc/passwd | grep " + curUser); ++ ++ curUser = curUser + ':'; ++ execCmd->start("bash", QStringList() << "-c" << "cat /etc/passwd | grep ^" + curUser + " | cut -d ':' -f 6"); + execCmd->waitForFinished(); + curUsrPawdInfo = execCmd->readAllStandardOutput(); +- execCmd->close(); +- +- curHome = curUsrPawdInfo.split(':'); +- +- return curHome[5]; ++ curHome = curUsrPawdInfo.replace(QRegExp("\n"), ""); ++ ++ return curHome; + } + + bool GetContent::checkLogPathExists(QString &logPath) diff --git a/nfs-logtools.spec b/nfs-logtools.spec index 7ce35d88f0a7cefaf7a80d75f65ddf75bdfcd99f..cb02c946e227835c91c076c2a67411af2f2db1d5 100644 --- a/nfs-logtools.spec +++ b/nfs-logtools.spec @@ -3,7 +3,7 @@ Name: nfs-logtools Version: 1.0.0 -Release: 5%{?dist} +Release: 6%{?dist} Summary: A log tools of Nfs. License: GPLv2+ Source0: %{name}-%{version}.tar.gz @@ -12,6 +12,7 @@ Patch1: 0002-adj-xsession-error-log-path.patch Patch2: 0003-auto-scaling-and-fix-error.patch Patch3: 0004-after-export-all-log-program-abort.patch Patch4: 0005-fix-cannot-reopen-when-program-crashes.patch +Patch5: 0006-fix-get-home-path-method.patch BuildRequires: qt5-qttools-devel qt5-qtbase-devel glibc-devel Requires: coreutils @@ -45,6 +46,9 @@ make %{?_smp_mflags} /usr/sbin/nfs-logtools %changelog +* Wed Oct 18 2023 ruizhe - 1.0.0-6 +- Fix get home path method + * Wed Oct 18 2023 ruizhe - 1.0.0-5 - Fix cannot reopen when program crashes