core: ignore errors from cg_create_and_attach() in test mode (#8401)
authorMichal Sekletar <msekletar@users.noreply.github.com>
Fri, 9 Mar 2018 22:30:32 +0000 (23:30 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 9 Mar 2018 22:30:32 +0000 (23:30 +0100)
commitaa77e234fce7413b7dd64f99ea51450f2e2e9dbd
treef3079b7581c87efc75b9d2931ed10a6774f1ddab
parent6fed2cc41f6cf45f293bb83c0d506438275e851c
core: ignore errors from cg_create_and_attach() in test mode (#8401)

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 try to setup cgroup hierarchy, but if that fails return error only
when not running in the test mode.

Fixes #8072
src/core/cgroup.c