core: don't create Requires for workdir if "missing ok"
authorMartin Wilck <mwilck@suse.com>
Wed, 24 Oct 2018 11:22:01 +0000 (13:22 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 25 Oct 2018 09:35:59 +0000 (11:35 +0200)
Don't add an implicit RequiresMountsFor depenency for the
WorkingDirectory of a unit if the "-" character was used to
indicate that "a missing working directory is not considered fatal"
(see systemd.exec(5)). Otherwise systemd might fail the unit
because of missing dependencies.

src/core/unit.c

index c8f4c7c..0df09d0 100644 (file)
@@ -964,7 +964,7 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
         assert(u);
         assert(c);
 
-        if (c->working_directory) {
+        if (c->working_directory && !c->working_directory_missing_ok) {
                 r = unit_require_mounts_for(u, c->working_directory, UNIT_DEPENDENCY_FILE);
                 if (r < 0)
                         return r;