/* This didn't work? Then let's try all prefixes of the destination */
- strcpy(prefix, pto);
- for (;;) {
- char *slash;
-
- slash = strrchr(prefix, '/');
- if (!slash)
- break;
-
- *slash = 0;
-
+ PATH_FOREACH_PREFIX(prefix, pto) {
r = cg_migrate_recursive(cfrom, pfrom, cto, prefix, ignore_self, rem);
if (r >= 0)
break;
}
}
- return r;
+ return 0;
}
static const char *normalize_controller(const char *controller) {
/* This didn't work? Then let's try all prefixes of
* the destination */
- strcpy(prefix, path);
- for (;;) {
- char *slash;
-
- slash = strrchr(prefix, '/');
- if (!slash)
- break;
-
- *slash = 0;
-
+ PATH_FOREACH_PREFIX(prefix, path) {
r = cg_attach(controller, prefix, pid);
if (r >= 0)
break;
}
}
- return r;
+ return 0;
}
int cg_set_group_access(
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;