diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-02-10 15:16:11 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-02-10 15:16:11 +0100 |
commit | c49970743eb51ab27b4b021bc64412ac74af83af (patch) | |
tree | e3efb1d5265387e826e1565f5480fbe9be28adc7 | |
parent | d0fd66a379ccf0096389faf4490a9ba986ef3458 (diff) |
path-lookup: try harder acquiring them $HOME of a user
Let's use get_home_dir() for figuring out the home directory, so that
there's a good chance we succeed figuring out unit locations even if
$HOME isn't set.
Fixes: #5260
-rw-r--r-- | src/shared/path-lookup.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c index 586ef64e72..dcfbab7b83 100644 --- a/src/shared/path-lookup.c +++ b/src/shared/path-lookup.c @@ -33,6 +33,7 @@ #include "stat-util.h" #include "string-util.h" #include "strv.h" +#include "user-util.h" #include "util.h" static int user_runtime_dir(char **ret, const char *suffix) { @@ -57,6 +58,7 @@ static int user_runtime_dir(char **ret, const char *suffix) { static int user_config_dir(char **ret, const char *suffix) { const char *e; char *j; + int r; assert(ret); @@ -64,11 +66,11 @@ static int user_config_dir(char **ret, const char *suffix) { if (e) j = strappend(e, suffix); else { - const char *home; + _cleanup_free_ char *home = NULL; - home = getenv("HOME"); - if (!home) - return -ENXIO; + r = get_home_dir(&home); + if (r < 0) + return r; j = strjoin(home, "/.config", suffix); } @@ -83,6 +85,7 @@ static int user_config_dir(char **ret, const char *suffix) { static int user_data_dir(char **ret, const char *suffix) { const char *e; char *j; + int r; assert(ret); assert(suffix); @@ -95,12 +98,11 @@ static int user_data_dir(char **ret, const char *suffix) { if (e) j = strappend(e, suffix); else { - const char *home; - - home = getenv("HOME"); - if (!home) - return -ENXIO; + _cleanup_free_ char *home = NULL; + r = get_home_dir(&home); + if (r < 0) + return r; j = strjoin(home, "/.local/share", suffix); } |