summaryrefslogtreecommitdiffstats
path: root/lib/Utils/DebugDump.cpp
diff options
context:
space:
mode:
authorZdenek Prikryl <zprikryl@redhat.com>2009-07-24 15:33:14 +0200
committerZdenek Prikryl <zprikryl@redhat.com>2009-07-24 15:33:14 +0200
commitf889932408f5912379f92e24c0e8f213a1f6c451 (patch)
tree62f6d249184082e0dd2bed25c6d656bbcbca0511 /lib/Utils/DebugDump.cpp
parent052e544305d6b1efde7d28f894ead8771cf62b03 (diff)
parent16db3cc595ab34f21a747d88fb9cdd340ac438f9 (diff)
downloadabrt-f889932408f5912379f92e24c0e8f213a1f6c451.tar.gz
abrt-f889932408f5912379f92e24c0e8f213a1f6c451.tar.xz
abrt-f889932408f5912379f92e24c0e8f213a1f6c451.zip
Merge branch 'master' of git://git.fedorahosted.org/abrt
Diffstat (limited to 'lib/Utils/DebugDump.cpp')
-rw-r--r--lib/Utils/DebugDump.cpp24
1 files changed, 3 insertions, 21 deletions
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp
index 36b48cc6..b2767bad 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;