X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Fcgroup-util.c;h=0bffebdac8d56ad27df8e06b516797f3d7a956ca;hp=73013d1d97f1b908fb61b9469b44d06261d9b237;hb=4b549144d82ea0f368321d149215f577049fffa6;hpb=ad929bcc27e2c6c1aa731053e45882686e9babab diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c index 73013d1d9..0bffebdac 100644 --- a/src/shared/cgroup-util.c +++ b/src/shared/cgroup-util.c @@ -794,6 +794,17 @@ int cg_uninstall_release_agent(const char *controller) { _cleanup_free_ char *fs = NULL; int r; + r = cg_get_path(controller, NULL, "notify_on_release", &fs); + if (r < 0) + return r; + + r = write_string_file(fs, "0"); + if (r < 0) + return r; + + free(fs); + fs = NULL; + r = cg_get_path(controller, NULL, "release_agent", &fs); if (r < 0) return r; @@ -802,7 +813,7 @@ int cg_uninstall_release_agent(const char *controller) { if (r < 0) return r; - return 0; + return 0; } int cg_is_empty(const char *controller, const char *path, bool ignore_self) { @@ -1115,7 +1126,7 @@ int cg_pid_get_path_shifted(pid_t pid, char **root, char **cgroup) { } int cg_path_decode_unit(const char *cgroup, char **unit){ - char *p, *e, *c, *s, *k; + char *e, *c, *s; assert(cgroup); assert(unit); @@ -1124,28 +1135,10 @@ int cg_path_decode_unit(const char *cgroup, char **unit){ c = strndupa(cgroup, e - cgroup); c = cg_unescape(c); - /* Could this be a valid unit name? */ - if (!unit_name_is_valid(c, true)) + if (!unit_name_is_valid(c, false)) return -EINVAL; - if (!unit_name_is_template(c)) - s = strdup(c); - else { - if (*e != '/') - return -EINVAL; - - e += strspn(e, "/"); - - p = strchrnul(e, '/'); - k = strndupa(e, p - e); - k = cg_unescape(k); - - if (!unit_name_is_valid(k, false)) - return -EINVAL; - - s = strdup(k); - } - + s = strdup(c); if (!s) return -ENOMEM; @@ -1518,9 +1511,7 @@ char *cg_unescape(const char *p) { } #define CONTROLLER_VALID \ - "0123456789" \ - "abcdefghijklmnopqrstuvwxyz" \ - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ + DIGITS LETTERS \ "_" bool cg_controller_is_valid(const char *p, bool allow_named) {