diff options
author | Zdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com> | 2009-08-14 17:43:42 +0200 |
---|---|---|
committer | Zdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com> | 2009-08-14 17:43:42 +0200 |
commit | 62dbb8f2725bd707fb4e00175f66b008d92a1a9b (patch) | |
tree | 6194abaefb128422542de2403a368bf47e61a68e | |
parent | 4739232edf3e57c32d108567c7e74b081b7ca0e3 (diff) | |
download | abrt-62dbb8f2725bd707fb4e00175f66b008d92a1a9b.tar.gz abrt-62dbb8f2725bd707fb4e00175f66b008d92a1a9b.tar.xz abrt-62dbb8f2725bd707fb4e00175f66b008d92a1a9b.zip |
.abrt directory in $HOME is created if it doesn't exist
-rw-r--r-- | src/Daemon/PluginManager.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp index f4fe2738..1f450d50 100644 --- a/src/Daemon/PluginManager.cpp +++ b/src/Daemon/PluginManager.cpp @@ -281,14 +281,43 @@ void CPluginManager::SetPluginSettings(const std::string& pName, std::string home = get_home_dir(atoi(pUID.c_str())); if (home != "") { - std::string confPath = home + "/.abrt/" + pName + "." + PLUGINS_CONF_EXTENSION; - SavePluginSettings(confPath, pSettings); + std::string confDir = home + "/.abrt"; + std::string confPath = confDir + "/" + pName + "." + PLUGINS_CONF_EXTENSION; uid_t uid = atoi(pUID.c_str()); struct passwd* pw = getpwuid(uid); gid_t gid = pw ? pw->pw_gid : uid; + + struct stat buf; + if (stat(confDir.c_str(), &buf) != 0) + { + if (mkdir(confDir.c_str(), 0700) == -1) + { + perror_msg("can't create dir '%s'", confDir.c_str()); + return; + } + if (chmod(confDir.c_str(), 0700) == -1) + { + perror_msg("can't change mod of dir '%s'", confDir.c_str()); + return; + } + if (chown(confDir.c_str(), uid, gid) == -1) + { + perror_msg("can't change '%s' ownership to %u:%u", confPath.c_str(), (int)uid, (int)gid); + return; + } + + } + else if (!S_ISDIR(buf.st_mode)) + { + perror_msg("'%s' is not a directory", confDir.c_str()); + return; + } + + SavePluginSettings(confPath, pSettings); if (chown(confPath.c_str(), uid, gid) == -1) { perror_msg("can't change '%s' ownership to %u:%u", confPath.c_str(), (int)uid, (int)gid); + return; } } } |