string.c: Use $HOME to get the home directory.
authorAndre Noll <maan@systemlinux.org>
Wed, 12 Sep 2007 11:36:20 +0000 (13:36 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 12 Sep 2007 11:36:20 +0000 (13:36 +0200)
This is actually simpler than using getpwuid(), and it shuts up a valgrind
warning as well.

string.c

index 60050ad7afaf822acd6883c08c222808ce1bbeab..0d7e05e66c3f8c88cb4738ff72ad9047f63cc07c 100644 (file)
--- a/string.c
+++ b/string.c
@@ -300,8 +300,8 @@ __must_check __malloc char *para_logname(void)
  */
 __must_check __malloc char *para_homedir(void)
 {
-       struct passwd *pw = getpwuid(getuid());
-       return para_strdup(pw? pw->pw_dir : "/tmp");
+       char *h = getenv("HOME");
+       return para_strdup(h? h : "/tmp");
 }
 
 /**