diff --git a/src/core/slice.c b/src/core/slice.c index c7701b4017f..fb4f23c1069 100644 --- a/src/core/slice.c +++ b/src/core/slice.c @@ -96,6 +96,10 @@ static int slice_verify(Slice *s) { if (r < 0) return log_unit_error_errno(UNIT(s), r, "Failed to determine parent slice: %m"); + /* If recursive errors are to be ignored, the parent slice should not be verified */ + if (UNIT(s)->manager && FLAGS_SET(UNIT(s)->manager->test_run_flags, MANAGER_TEST_RUN_IGNORE_DEPENDENCIES)) + return 0; + if (parent ? !unit_has_name(UNIT_GET_SLICE(UNIT(s)), parent) : !!UNIT_GET_SLICE(UNIT(s))) return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Located outside of parent slice. Refusing."); diff --git a/test/units/testsuite-65.sh b/test/units/testsuite-65.sh index 7183a4e1721..66db42d7593 100755 --- a/test/units/testsuite-65.sh +++ b/test/units/testsuite-65.sh @@ -236,6 +236,18 @@ set -e rm /tmp/testfile.service rm /tmp/testfile2.service +cat </tmp/sample.service +[Unit] +Description = A Sample Service + +[Service] +ExecStart = echo hello +Slice=support.slice +EOF + +# Zero exit status since no additional dependencies are recursively loaded when the unit file is loaded +systemd-analyze verify --recursive-errors=no /tmp/sample.service + cat </tmp/testfile.service [Service] ExecStart = echo hello