summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com>2009-08-11 18:35:26 +0200
committerZdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com>2009-08-11 18:35:26 +0200
commit3cfaec88a8ec167cb345de086b65e47900112bf3 (patch)
tree26ae9c1baaaee91f39b7ed04a5ea3b917c1526fa
parent0068473524278198469bf2f53ea19cbcde75b189 (diff)
downloadabrt-3cfaec88a8ec167cb345de086b65e47900112bf3.tar.gz
abrt-3cfaec88a8ec167cb345de086b65e47900112bf3.tar.xz
abrt-3cfaec88a8ec167cb345de086b65e47900112bf3.zip
new function for gettings user's home directory
-rw-r--r--inc/abrtlib.h2
-rw-r--r--lib/Utils/xfuncs.cpp6
2 files changed, 8 insertions, 0 deletions
diff --git a/inc/abrtlib.h b/inc/abrtlib.h
index 8e3f1f4e..5721c6fa 100644
--- a/inc/abrtlib.h
+++ b/inc/abrtlib.h
@@ -113,4 +113,6 @@ off_t copyfd_eof(int src_fd, int dst_fd);
off_t copyfd_size(int src_fd, int dst_fd, off_t size);
void copyfd_exact_size(int src_fd, int dst_fd, off_t size);
+std::string get_home_dir(int uid);
+
#endif
diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp
index 60c2eb4f..c8aee376 100644
--- a/lib/Utils/xfuncs.cpp
+++ b/lib/Utils/xfuncs.cpp
@@ -246,3 +246,9 @@ void xstat(const char *name, struct stat *stat_buf)
if (stat(name, stat_buf))
perror_msg_and_die("can't stat '%s'", name);
}
+
+std::string get_home_dir(int uid)
+{
+ struct passwd* pw = getpwuid(uid);
+ return pw ? pw->pw_dir : "";
+}