diff options
| author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-08-06 16:19:07 +0200 |
|---|---|---|
| committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-08-06 16:19:07 +0200 |
| commit | 84348ccea878d509f838927e1bf393e5443d3ac8 (patch) | |
| tree | d7dc8bdc80b18a6137f94415761ec95c1df8e005 /lib/Utils/DebugDump.cpp | |
| parent | 9a3268d970142f0dfb4e3e77c66c9637bf87fbda (diff) | |
| parent | 26c6665308b5a99d02308099118b23b2716dacc0 (diff) | |
| download | abrt-84348ccea878d509f838927e1bf393e5443d3ac8.tar.gz abrt-84348ccea878d509f838927e1bf393e5443d3ac8.tar.xz abrt-84348ccea878d509f838927e1bf393e5443d3ac8.zip | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Conflicts:
lib/CommLayer/DBusServerProxy.h
Diffstat (limited to 'lib/Utils/DebugDump.cpp')
| -rw-r--r-- | lib/Utils/DebugDump.cpp | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index 3297579..f63a8c6 100644 --- a/lib/Utils/DebugDump.cpp +++ b/lib/Utils/DebugDump.cpp @@ -19,25 +19,15 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "abrtlib.h" #include "DebugDump.h" #include "ABRTException.h" #include <fstream> #include <iostream> #include <sstream> #include <cerrno> -#include <sys/types.h> -#include <sys/stat.h> -#include <dirent.h> #include <sys/utsname.h> -#include <limits.h> -#include <fcntl.h> -#include <ctype.h> -#include <time.h> -#include <unistd.h> #include <magic.h> -#include <string.h> -#include <pwd.h> -#include <stdlib.h> #include "CommLayerInner.h" // BUG? in C/C++, compiler may assume that function address is never NULL @@ -193,7 +183,7 @@ void CDebugDump::UnLock() } } -void CDebugDump::Create(const std::string& pDir, const std::string& pUID) +void CDebugDump::Create(const std::string& pDir, uid_t uid) { if (m_bOpened) { @@ -221,16 +211,16 @@ 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); } - 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) + gid_t gid = pw ? pw->pw_gid : uid; + if (chown(m_sDebugDumpDir.c_str(), uid, gid) == -1) { - UnLock(); - m_bOpened = false; - throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::Create(): Cannot change ownership, dir: " + pDir); + /* if /var/cache/abrt is writable by all, _aborting_ here is not useful */ + /* let's just warn */ + perror_msg("can't change '%s' ownership to %u:%u", m_sDebugDumpDir.c_str(), (int)uid, (int)gid); } - SaveText(FILENAME_UID, pUID); + SaveText(FILENAME_UID, ssprintf("%u", (int)uid)); SaveKernelArchitectureRelease(); SaveTime(); } @@ -239,7 +229,7 @@ static void DeleteFileDir(const std::string& pDir) { DIR *dir = opendir(pDir.c_str()); if (!dir) - return; + return; struct dirent *dent; while ((dent = readdir(dir)) != NULL) |
