From 3cfaec88a8ec167cb345de086b65e47900112bf3 Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Tue, 11 Aug 2009 18:35:26 +0200 Subject: new function for gettings user's home directory --- inc/abrtlib.h | 2 ++ lib/Utils/xfuncs.cpp | 6 ++++++ 2 files changed, 8 insertions(+) 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 : ""; +} -- cgit