From b04dc4d457522b33bb8b586d584469952b75991f Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sat, 15 May 2021 10:25:24 +0200 Subject: [PATCH] Ensure services in plugins and from finit.c belong to a cgroup The udevd, dbus, bundled watchdog, and others were started without a valid cgroup. This is a workaround to ensure they are assigned one. Signed-off-by: Joachim Wiberg --- plugins/dbus.c | 2 +- plugins/hotplug.c | 6 +++--- plugins/modules-load.c | 5 ++--- src/finit.c | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/dbus.c b/plugins/dbus.c index 19dcc756..472bac41 100644 --- a/plugins/dbus.c +++ b/plugins/dbus.c @@ -64,7 +64,7 @@ static void setup(void *arg) remove("/var/run/dbus/pid"); /* Register service with Finit */ - snprintf(line, sizeof(line), "[S12345789] @%s:%s %s %s -- %s", + snprintf(line, sizeof(line), "[S12345789] cgroup.system @%s:%s %s %s -- %s", DAEMONUSER, DAEMONUSER, cmd, ARGS, DESC); if (service_register(SVC_TYPE_SERVICE, line, global_rlimit, NULL)) _pe("Failed registering %s", DAEMON); diff --git a/plugins/hotplug.c b/plugins/hotplug.c index 11d15b35..b0bd071c 100644 --- a/plugins/hotplug.c +++ b/plugins/hotplug.c @@ -48,17 +48,17 @@ static void setup(void *arg) path = which("/lib/systemd/systemd-udevd"); if (path) { /* Register udevd as a monitored service */ - snprintf(cmd, sizeof(cmd), "[S12345789] pid:udevd name:udevd log %s " + snprintf(cmd, sizeof(cmd), "[S12345789] cgroup.system pid:udevd name:udevd log %s " "-- Device event managing daemon", path); if (service_register(SVC_TYPE_SERVICE, cmd, global_rlimit, NULL)) { _pe("Failed registering %s", path); } else { - snprintf(cmd, sizeof(cmd), ":1 [S] log " + snprintf(cmd, sizeof(cmd), "cgroup.init :1 [S] log " "udevadm trigger -c add -t devices " "-- Requesting device events"); service_register(SVC_TYPE_RUN, cmd, global_rlimit, NULL); - snprintf(cmd, sizeof(cmd), ":2 [S] log " + snprintf(cmd, sizeof(cmd), "cgroup.init :2 [S] log " "udevadm trigger -c add -t subsystems " "-- Requesting subsystem events"); service_register(SVC_TYPE_RUN, cmd, global_rlimit, NULL); diff --git a/plugins/modules-load.c b/plugins/modules-load.c index a8bc7d04..f0845f29 100644 --- a/plugins/modules-load.c +++ b/plugins/modules-load.c @@ -36,7 +36,7 @@ #define MODULES_LOAD_PATH "/etc/modules-load.d" #endif #define SERVICE_LINE \ - ":%d name:modprobe.%s [2345] /sbin/modprobe %s %s -- Kernel module: %s" + "cgroup.init :%d name:modprobe.%s [2345] /sbin/modprobe %s %s -- Kernel module: %s" static void load(void *arg) { @@ -71,8 +71,7 @@ static void load(void *arg) mod = strtok_r(mod, " ", &args); - snprintf(cmd, sizeof(cmd), SERVICE_LINE, - index, mod, mod, args, mod); + snprintf(cmd, sizeof(cmd), SERVICE_LINE, index, mod, mod, args, mod); service_register(SVC_TYPE_TASK, cmd, global_rlimit, NULL); index++; diff --git a/src/finit.c b/src/finit.c index 516e8d8f..dfbc0c6c 100644 --- a/src/finit.c +++ b/src/finit.c @@ -590,7 +590,7 @@ int main(int argc, char *argv[]) * Start built-in watchdogd as soon as possible, if enabled */ if (whichp(FINIT_LIBPATH_ "/watchdogd") && fexist(WDT_DEVNODE)) { - service_register(SVC_TYPE_SERVICE, "[123456789] name:watchdog :finit " FINIT_LIBPATH_ "/watchdogd -- Finit watchdog daemon", global_rlimit, NULL); + service_register(SVC_TYPE_SERVICE, "[123456789] cgroup.init name:watchdog :finit " FINIT_LIBPATH_ "/watchdogd -- Finit watchdog daemon", global_rlimit, NULL); wdog = svc_find_by_nameid("watchdog", "finit"); }