From: Daan De Meyer Date: Wed, 15 May 2024 18:54:33 +0000 (+0200) Subject: core: Skip private /tmp for generators in manager test runs X-Git-Tag: v256-rc3~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=452f91d8469882f623c3b2c637ce85037ec73621;p=thirdparty%2Fsystemd.git core: Skip private /tmp for generators in manager test runs For manager test runs, the generator output paths are located in /tmp, which means that if we mount a private /tmp for generators, we lose all the generated units (actually the generators will just fail because the directories don't exist, but if they did exist, we'd still lose all the units). Let's avoid the problem by skipping the private /tmp for manager test runs. This also avoids any possible privilege issues with mounting a private /tmp that might happen in this scenario. --- diff --git a/src/core/manager.c b/src/core/manager.c index 43fbd0e1e4e..90e72b0c025 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -4161,7 +4161,7 @@ static int manager_run_generators(Manager *m) { /* On some systems /tmp/ doesn't exist, and on some other systems we cannot create it at all. Avoid * trying to mount a private tmpfs on it as there's no one size fits all. */ - if (is_dir("/tmp", /* follow= */ false) > 0) + if (is_dir("/tmp", /* follow= */ false) > 0 && !MANAGER_IS_TEST_RUN(m)) flags |= FORK_PRIVATE_TMP; r = safe_fork("(sd-gens)", flags, NULL); diff --git a/test/units/TEST-65-ANALYZE.sh b/test/units/TEST-65-ANALYZE.sh index 59dfd4fb576..5f650ade05a 100755 --- a/test/units/TEST-65-ANALYZE.sh +++ b/test/units/TEST-65-ANALYZE.sh @@ -302,6 +302,9 @@ systemd-analyze security --offline=true /tmp/testfile.service # Ensure we print the list of ACLs, see https://github.com/systemd/systemd/issues/23185 systemd-analyze security --offline=true /tmp/testfile.service | grep -q -F "/dev/sda" +# Make sure that running generators under systemd-analyze verify works. +systemd-analyze verify --generators /tmp/testfile.service + rm /tmp/testfile.service cat </tmp/img/usr/lib/systemd/system/testfile.service