[systemd-devel] [PATCH] bus-control: Fix cgroup handling

Denis Kenzior denkenz at gmail.com
Sat Aug 16 11:55:00 PDT 2014


On systems without properly setup systemd, cg_get_root_path returns
-ENOENT.  This means that busctl doesn't display much information.

busctl monitor also fails whenever it intercepts messages.

This fix fakes creates a fake "/" root cgroup which lets busctl work
on such systems.
---
 src/libsystemd/sd-bus/bus-control.c | 4 +++-
 src/libsystemd/sd-bus/bus-kernel.c  | 5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index 076bbce..8c5c669 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -497,7 +497,9 @@ static int bus_get_owner_kdbus(
 
                                 if (!bus->cgroup_root) {
                                         r = cg_get_root_path(&bus->cgroup_root);
-                                        if (r < 0)
+                                        if (r == -ENOENT)
+                                                bus->cgroup_root = strdup("/");
+                                        else if (r < 0)
                                                 goto fail;
                                 }
 
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 8b961c3..e49298d 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -27,6 +27,7 @@
 #include <malloc.h>
 #include <sys/mman.h>
 #include <sys/prctl.h>
+#include <string.h>
 
 #include "util.h"
 #include "strv.h"
@@ -544,7 +545,9 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
 
                         if (!bus->cgroup_root) {
                                 r = cg_get_root_path(&bus->cgroup_root);
-                                if (r < 0)
+                                if (r == -ENOENT)
+                                        bus->cgroup_root = strdup("/");
+                                else if (r < 0)
                                         goto fail;
                         }
 
-- 
1.8.5.5



More information about the systemd-devel mailing list