chiark / gitweb /
core: don't fail to run services in --user instances if $HOME is missing
authorLennart Poettering <lennart@poettering.net>
Thu, 12 Feb 2015 11:21:16 +0000 (12:21 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 12 Feb 2015 11:21:16 +0000 (12:21 +0100)
Otherwise we cannot even invoke systemd-exit.service anymore, thus not
even exit.

https://bugs.freedesktop.org/show_bug.cgi?id=83100
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759320

src/core/execute.c
src/core/execute.h
src/core/unit.c

index 7b071e8..1f6072c 100644 (file)
@@ -1617,7 +1617,8 @@ static int exec_child(
                                 return -errno;
                         }
 
-                if (chdir(context->working_directory ? context->working_directory : "/") < 0) {
+                if (chdir(context->working_directory ?: "/") < 0 &&
+                    !context->working_directory_missing_ok) {
                         *exit_status = EXIT_CHDIR;
                         return -errno;
                 }
index 2c20139..153867c 100644 (file)
@@ -99,6 +99,7 @@ struct ExecContext {
 
         struct rlimit *rlimit[_RLIMIT_MAX];
         char *working_directory, *root_directory;
+        bool working_directory_missing_ok;
 
         mode_t umask;
         int oom_score_adjust;
index 67425ba..514b649 100644 (file)
@@ -3178,6 +3178,10 @@ int unit_patch_contexts(Unit *u) {
                         r = get_home_dir(&ec->working_directory);
                         if (r < 0)
                                 return r;
+
+                        /* Allow user services to run, even if the
+                         * home directory is missing */
+                        ec->working_directory_missing_ok = true;
                 }
 
                 if (u->manager->running_as == SYSTEMD_USER &&