diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-07-24 12:12:59 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-07-24 12:12:59 +0200 |
commit | 280334787ea74be1c5234849672c69dbfdb2f201 (patch) | |
tree | 2781aaed86df59efad57a608a86892a190efa91e /lib/Utils | |
parent | 337fc151e4b2682de4c3b2496045e4054080b844 (diff) | |
download | abrt-280334787ea74be1c5234849672c69dbfdb2f201.tar.gz abrt-280334787ea74be1c5234849672c69dbfdb2f201.tar.xz abrt-280334787ea74be1c5234849672c69dbfdb2f201.zip |
remove GetGIDFromUID (two copies): getpwuid does the same
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Utils')
-rw-r--r-- | lib/Utils/DebugDump.cpp | 24 | ||||
-rw-r--r-- | lib/Utils/DebugDump.h | 1 |
2 files changed, 3 insertions, 22 deletions
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index 6fd135e3..465b7ab7 100644 --- a/lib/Utils/DebugDump.cpp +++ b/lib/Utils/DebugDump.cpp @@ -178,25 +178,6 @@ void CDebugDump::UnLock() } } -std::string CDebugDump::GetGIDFromUID(const std::string& pUID) -{ - std::stringstream ret; - struct passwd* pw; - while (( pw = getpwent()) != NULL) - { - if (pw->pw_uid == atoi(pUID.c_str())) - { - ret << pw->pw_gid; - } - } - setpwent(); - if (ret.str() == "") - { - ret << "-1"; - } - return ret.str(); -} - void CDebugDump::Create(const std::string& pDir, const std::string& pUID) { if (m_bOpened) @@ -225,8 +206,9 @@ void CDebugDump::Create(const std::string& pDir, const std::string& pUID) m_bOpened = false; throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::Create(): Cannot change permissions, dir: " + pDir); } - std::string GID = GetGIDFromUID(pUID); - if (chown(m_sDebugDumpDir.c_str(), atoi(pUID.c_str()), atoi(GID.c_str())) == -1) + uid_t uid = atoi(pUID.c_str()); + struct passwd* pw = getpwuid(uid); + if (chown(m_sDebugDumpDir.c_str(), uid, pw ? pw->pw_gid : uid) == -1) { UnLock(); m_bOpened = false; diff --git a/lib/Utils/DebugDump.h b/lib/Utils/DebugDump.h index 3b47956c..a09a913d 100644 --- a/lib/Utils/DebugDump.h +++ b/lib/Utils/DebugDump.h @@ -66,7 +66,6 @@ class CDebugDump bool IsTextFile(const std::string& pName); std::string RemoveBackSlashes(const std::string& pDir); - std::string GetGIDFromUID(const std::string& pUID); public: CDebugDump(); |