diff options
author | Karel Klic <kklic@redhat.com> | 2010-04-29 15:18:17 +0200 |
---|---|---|
committer | Karel Klic <kklic@redhat.com> | 2010-04-29 15:18:17 +0200 |
commit | a345b357a14f7e5ad259160f69d9c2129f2c4e01 (patch) | |
tree | e2f936e07ad59fb3f23f54f68e8df65ceb03d04d | |
parent | e465938fa36e51eff4bd62b736bcc8d66f4d0785 (diff) | |
download | abrt-a345b357a14f7e5ad259160f69d9c2129f2c4e01.tar.gz abrt-a345b357a14f7e5ad259160f69d9c2129f2c4e01.tar.xz abrt-a345b357a14f7e5ad259160f69d9c2129f2c4e01.zip |
get_home_dir returns const char* instead of std::string
-rw-r--r-- | lib/Utils/xfuncs.cpp | 4 | ||||
-rw-r--r-- | lib/Utils/xfuncs.h | 6 | ||||
-rw-r--r-- | src/Daemon/PluginManager.cpp | 6 |
3 files changed, 9 insertions, 7 deletions
diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp index 53c10f9a..89273675 100644 --- a/lib/Utils/xfuncs.cpp +++ b/lib/Utils/xfuncs.cpp @@ -276,11 +276,11 @@ void xstat(const char *name, struct stat *stat_buf) perror_msg_and_die("can't stat '%s'", name); } -std::string get_home_dir(uid_t uid) +const char *get_home_dir(uid_t uid) { struct passwd* pw = getpwuid(uid); // TODO: handle errno - return pw ? pw->pw_dir : ""; + return pw ? pw->pw_dir : NULL; } // Die if we can't open a file and return a fd diff --git a/lib/Utils/xfuncs.h b/lib/Utils/xfuncs.h index aa672af2..93baa175 100644 --- a/lib/Utils/xfuncs.h +++ b/lib/Utils/xfuncs.h @@ -79,6 +79,11 @@ extern bool string_to_bool(const char *s); extern void xsetreuid(uid_t ruid, uid_t euid); extern void xsetregid(gid_t rgid, gid_t egid); +/* Do not pass the returned pointer to free(). + Do not modify the contents of the returned string. + NULL is returned in the case of failure. */ +extern const char *get_home_dir(uid_t uid); + #ifdef __cplusplus } #endif @@ -86,7 +91,6 @@ extern void xsetregid(gid_t rgid, gid_t egid); #ifdef __cplusplus std::string ssprintf(const char *format, ...); std::string concat_path_file(const char *path, const char *filename); -std::string get_home_dir(uid_t uid); #endif #endif diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp index f01d9435..47b72e01 100644 --- a/src/Daemon/PluginManager.cpp +++ b/src/Daemon/PluginManager.cpp @@ -381,11 +381,9 @@ void CPluginManager::SetPluginSettings(const char *pName, return; } - string home = get_home_dir(xatoi_u(pUID.c_str())); - if (home == "") - { + const char *home = get_home_dir(xatoi_u(pUID.c_str())); + if (home == NULL || strlen(home) == 0) return; - } string confDir = home + "/.abrt"; string confPath = confDir + "/" + pName + "."PLUGINS_CONF_EXTENSION; |