]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
path-lookup: try harder acquiring them $HOME of a user
authorLennart Poettering <lennart@poettering.net>
Fri, 10 Feb 2017 14:16:11 +0000 (15:16 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 10 Feb 2017 14:16:11 +0000 (15:16 +0100)
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
src/shared/path-lookup.c

index 586ef64e7226094a3a471d23145f9d233f6328ba..dcfbab7b831f5d00d5f849922cd2db9cbfaa1919 100644 (file)
@@ -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);
         }