From e4e9562c9250423c45a52009659b632eab905f8c Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 30 Mar 2012 01:43:38 +0900 Subject: [PATCH] Get the home directory of the effective user ID using getpwuid() if $HOME is not defined. --- src/util.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/util.cc b/src/util.cc index 9f6ad391..466f6751 100644 --- a/src/util.cc +++ b/src/util.cc @@ -35,6 +35,8 @@ #include "util.h" #include +#include +#include #include #include @@ -1008,7 +1010,12 @@ std::string getHomeDir() } } } -#endif +#else // !__MINGW32__ + passwd* pw = getpwuid(geteuid()); + if(pw && pw->pw_dir) { + return pw->pw_dir; + } +#endif // !__MINGW32__ return A2STR::NIL; } }