summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/execute.c3
-rw-r--r--src/core/execute.h1
-rw-r--r--src/core/unit.c4
3 files changed, 7 insertions, 1 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index 7b071e8c9e..1f6072c6ab 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -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;
}
diff --git a/src/core/execute.h b/src/core/execute.h
index 2c201399e3..153867c7b3 100644
--- a/src/core/execute.h
+++ b/src/core/execute.h
@@ -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;
diff --git a/src/core/unit.c b/src/core/unit.c
index 67425ba913..514b6491ce 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -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 &&