]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pid1: only add a Wants= type dependency on /tmp when PrivateTmp=yes
authorFranck Bui <fbui@suse.com>
Fri, 28 Aug 2020 14:03:06 +0000 (16:03 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 7 Jun 2021 12:10:56 +0000 (14:10 +0200)
We support that tmp.mount being masked, and this should not be considered an
error.

src/core/unit.c

index 42882dbd28da56108a651fd04cd284c0f86e78ba..c6b17afa51873aeb34b274dd461a87de54396268 100644 (file)
@@ -1282,13 +1282,18 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
         }
 
         if (c->private_tmp) {
-                const char *p;
 
-                FOREACH_STRING(p, "/tmp", "/var/tmp") {
-                        r = unit_require_mounts_for(u, p, UNIT_DEPENDENCY_FILE);
-                        if (r < 0)
-                                return r;
-                }
+                /* FIXME: for now we make a special case for /tmp and add a weak dependency on
+                 * tmp.mount so /tmp being masked is supported. However there's no reason to treat
+                 * /tmp specifically and masking other mount units should be handled more
+                 * gracefully too, see PR#16894. */
+                r = unit_add_two_dependencies_by_name(u, UNIT_AFTER, UNIT_WANTS, "tmp.mount", true, UNIT_DEPENDENCY_FILE);
+                if (r < 0)
+                        return r;
+
+                r = unit_require_mounts_for(u, "/var/tmp", UNIT_DEPENDENCY_FILE);
+                if (r < 0)
+                        return r;
 
                 r = unit_add_dependency_by_name(u, UNIT_AFTER, SPECIAL_TMPFILES_SETUP_SERVICE, true, UNIT_DEPENDENCY_FILE);
                 if (r < 0)