From 0c6a0d55fa4146414f4a8c79adbfde0f3a36328f Mon Sep 17 00:00:00 2001 From: "Costa Tsaousis (ktsaou)" Date: Sun, 1 May 2016 23:15:06 +0300 Subject: [PATCH] cgroups: properly disable certain cgroups --- src/sys_fs_cgroup.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/sys_fs_cgroup.c b/src/sys_fs_cgroup.c index 38fddcda..4f12cadc 100644 --- a/src/sys_fs_cgroup.c +++ b/src/sys_fs_cgroup.c @@ -803,20 +803,25 @@ void find_dir_in_subdirs(const char *base, const char *this, void (*callback)(co if(de->d_type == DT_DIR) { if(enabled == -1) { + const char *r = relative_path; + if(*r == '\0') r = "/"; + else if (*r == '/') r++; + // we check for this option here // so that the config will not have settings // for leaf directories char option[FILENAME_MAX + 1]; - snprintf(option, FILENAME_MAX, "search for cgroups under %s", (*relative_path == '\0')?"/":relative_path); + snprintf(option, FILENAME_MAX, "search for cgroups under %s", r); + option[FILENAME_MAX] = '\0'; int def = 1; - size_t len = strlen(this); - if((len > 5 && !strncmp(&this[len - 5], ".user", 5)) || - !strcmp(this, "system.slice") || - !strcmp(this, "user.slice") || - !strcmp(this, "system") || - !strcmp(this, "user") || - !strcmp(this, "systemd")) + size_t len = strlen(r); + if((len > 5 && !strncmp(&r[len - 5], ".user", 5)) || + !strcmp(r, "system.slice") || + !strcmp(r, "user.slice") || + !strcmp(r, "system") || + !strcmp(r, "user") || + !strcmp(r, "systemd")) def = 0; enabled = config_get_boolean("plugin:cgroups", option, def); -- 2.39.2