]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: don't setup init.scope in test mode (#8380)
authorMichal Sekletar <msekletar@users.noreply.github.com>
Wed, 7 Mar 2018 15:41:41 +0000 (16:41 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 7 Mar 2018 15:41:41 +0000 (16:41 +0100)
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.

src/core/manager.c

index 84adb9c6660f5c126ce971b3832aaa1fdeccc824..cc9a17a2fd42198a9d6d760600450708b5cf3275 100644 (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)