if (payload) {
__lxc_unused __do_close_prot_errno int fd = move_fd(h->cgfd_con);
- h->cgfd_con = -EBADF;
- full_path = h->container_full_path;
+ full_path = move_ptr(h->container_full_path);
} else {
__lxc_unused __do_close_prot_errno int fd = move_fd(h->cgfd_mon);
- h->cgfd_mon = -EBADF;
- full_path = h->monitor_full_path;
+ full_path = move_ptr(h->monitor_full_path);
}
- if (rmdir(full_path))
+ if (full_path && rmdir(full_path))
SYSWARN("Failed to rmdir(\"%s\") cgroup", full_path);
-
- if (payload)
- h->container_full_path = NULL;
- else
- h->monitor_full_path = NULL;
}
__cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
CGROUP_CREATE_RETRY, NULL);
} else if (ops->cgroup_pattern) {
__cgroup_tree = lxc_string_replace("%n", handler->name, ops->cgroup_pattern);
+ if (!__cgroup_tree)
+ return ret_set_errno(false, ENOMEM);
+
cgroup_tree = __cgroup_tree;
- monitor_cgroup = must_concat(&len, cgroup_tree,
+ monitor_cgroup = must_concat(&len, cgroup_tree, "/",
+ DEFAULT_MONITOR_CGROUP,
CGROUP_CREATE_RETRY, NULL);
} else {
+ cgroup_tree = NULL;
monitor_cgroup = must_concat(&len, DEFAULT_MONITOR_CGROUP_PREFIX,
handler->name,
CGROUP_CREATE_RETRY, NULL);
CGROUP_CREATE_RETRY, NULL);
} else if (ops->cgroup_pattern) {
__cgroup_tree = lxc_string_replace("%n", handler->name, ops->cgroup_pattern);
+ if (!__cgroup_tree)
+ return ret_set_errno(false, ENOMEM);
+
cgroup_tree = __cgroup_tree;
- container_cgroup = must_concat(&len, cgroup_tree,
+ container_cgroup = must_concat(&len, cgroup_tree, "/",
+ DEFAULT_PAYLOAD_CGROUP,
CGROUP_CREATE_RETRY, NULL);
} else {
+ cgroup_tree = NULL;
container_cgroup = must_concat(&len, DEFAULT_PAYLOAD_CGROUP_PREFIX,
handler->name,
CGROUP_CREATE_RETRY, NULL);
free(user_lxc_path);
user_lxc_path = copy_global_config_value(slider1);
remove_trailing_slashes(user_lxc_path);
- values[i] = user_lxc_path;
- user_lxc_path = NULL;
+ values[i] = move_ptr(user_lxc_path);
goto out;
}
/* could not find value, use default */
if (strcmp(option_name, "lxc.lxcpath") == 0) {
remove_trailing_slashes(user_lxc_path);
- values[i] = user_lxc_path;
- user_lxc_path = NULL;
- }
- else if (strcmp(option_name, "lxc.default_config") == 0) {
- values[i] = user_default_config_path;
- user_default_config_path = NULL;
- }
- else if (strcmp(option_name, "lxc.cgroup.pattern") == 0) {
- values[i] = user_cgroup_pattern;
- user_cgroup_pattern = NULL;
- }
- else
+ values[i] = move_ptr(user_lxc_path);
+ } else if (strcmp(option_name, "lxc.default_config") == 0) {
+ values[i] = move_ptr(user_default_config_path);
+ } else if (strcmp(option_name, "lxc.cgroup.pattern") == 0) {
+ values[i] = move_ptr(user_cgroup_pattern);
+ } else {
values[i] = (*ptr)[1];
+ }
/* special case: if default value is NULL,
* and there is no config, don't view that