diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-09-26 19:57:58 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-09-26 20:20:30 +0200 |
commit | baa89da40a1d42242c9c62603501ada7e9e52613 (patch) | |
tree | 12578bcc99d29522614a16e03b4daaf625d52bf0 /src/shared/cgroup-util.c | |
parent | 2b3ab29de466ae6bd7c3243a5a48c7291cc2af0a (diff) |
cgroup: when referencing cgroup controller trees allow omission of the path
Diffstat (limited to 'src/shared/cgroup-util.c')
-rw-r--r-- | src/shared/cgroup-util.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c index dc0fe85ee2..f57f2b2c42 100644 --- a/src/shared/cgroup-util.c +++ b/src/shared/cgroup-util.c @@ -1003,19 +1003,28 @@ int cg_split_spec(const char *spec, char **controller, char **path) { return -EINVAL; } - u = strdup(e+1); - if (!u) { - free(t); - return -ENOMEM; - } - if (!path_is_safe(u) || - !path_is_absolute(u)) { - free(t); - free(u); - return -EINVAL; - } + if (streq(e+1, "")) { + u = strdup("/"); + if (!u) { + free(t); + return -ENOMEM; + } + } else { + u = strdup(e+1); + if (!u) { + free(t); + return -ENOMEM; + } - path_kill_slashes(u); + if (!path_is_safe(u) || + !path_is_absolute(u)) { + free(t); + free(u); + return -EINVAL; + } + + path_kill_slashes(u); + } if (controller) *controller = t; |