core: don't setup init.scope in test mode (#8380)

Reproducer:

$ meson build && cd build
$ ninja
$ sudo useradd test
$ sudo su test
$ ./systemd --system --test
...
Failed to create /user.slice/user-1000.slice/session-6.scope/init.scope control group: Permission denied
Failed to allocate manager object: Permission denied

Above error message is caused by the fact that user test didn't have its
own session and we tried to set up init.scope already running as user
test in the directory owned by different user.

Let's skip setting up init.scope altogether since we won't be launching
processes anyway.
This commit is contained in:
Michal Sekletar 2018-03-07 16:41:41 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent 6f10433df7
commit a9e8ecf037

View file

@ -759,9 +759,11 @@ int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **_m) {
if (r < 0)
goto fail;
r = manager_setup_cgroup(m);
if (r < 0)
goto fail;
if (test_run_flags == 0) {
r = manager_setup_cgroup(m);
if (r < 0)
goto fail;
}
r = manager_setup_time_change(m);
if (r < 0)