}
/* lxc_preserve_namespaces: open /proc/@pid/ns/@ns for each namespace specified
- * in clone_flags.
+ * in ns_clone_flags.
* Return true on success, false on failure.
*/
-static bool lxc_preserve_namespaces(struct lxc_handler *handler, int clone_flags, pid_t pid)
+static bool lxc_preserve_namespaces(struct lxc_handler *handler, int ns_clone_flags, pid_t pid)
{
int i;
handler->nsfd[i] = -EBADF;
for (i = 0; i < LXC_NS_MAX; i++) {
- if ((clone_flags & ns_info[i].clone_flag) == 0)
+ if ((ns_clone_flags & ns_info[i].clone_flag) == 0)
continue;
handler->nsfd[i] = lxc_preserve_ns(pid, ns_info[i].proc_name);
memset(handler, 0, sizeof(struct lxc_handler));
- handler->clone_flags = -1;
+ handler->ns_clone_flags = -1;
handler->pinfd = -1;
/* Unshare CLONE_NEWNET after CLONE_NEWUSER. See
* https://github.com/lxc/lxd/issues/1978.
*/
- if ((handler->clone_flags & (CLONE_NEWNET | CLONE_NEWUSER)) ==
+ if ((handler->ns_clone_flags & (CLONE_NEWNET | CLONE_NEWUSER)) ==
(CLONE_NEWNET | CLONE_NEWUSER)) {
ret = unshare(CLONE_NEWNET);
if (ret < 0) {
*
* 8:cpuset:/
*/
- if (handler->clone_flags & CLONE_NEWCGROUP) {
+ if (handler->ns_clone_flags & CLONE_NEWCGROUP) {
ret = unshare(CLONE_NEWCGROUP);
if (ret < 0) {
INFO("Failed to unshare CLONE_NEWCGROUP");
for (i = 0; i < LXC_NS_MAX; i++) {
if (conf->ns_keep != 0) {
if ((conf->ns_keep & ns_info[i].clone_flag) == 0)
- handler->clone_flags |= ns_info[i].clone_flag;
+ handler->ns_clone_flags |= ns_info[i].clone_flag;
} else if (conf->ns_clone != 0) {
if ((conf->ns_clone & ns_info[i].clone_flag) > 0)
- handler->clone_flags |= ns_info[i].clone_flag;
+ handler->ns_clone_flags |= ns_info[i].clone_flag;
} else {
if (i == LXC_NS_USER && lxc_list_empty(&handler->conf->id_map))
continue;
if (i == LXC_NS_CGROUP && !cgns_supported())
continue;
- handler->clone_flags |= ns_info[i].clone_flag;
+ handler->ns_clone_flags |= ns_info[i].clone_flag;
}
if (!conf->ns_share[i])
continue;
- handler->clone_flags &= ~ns_info[i].clone_flag;
+ handler->ns_clone_flags &= ~ns_info[i].clone_flag;
TRACE("Sharing %s namespace", ns_info[i].proc_name);
}
DEBUG("Inherited %s namespace", ns_info[i].proc_name);
}
- flags = handler->on_clone_flags;
+ flags = handler->ns_on_clone_flags;
flags |= CLONE_PARENT;
handler->pid = lxc_raw_clone_cb(do_start, handler, flags);
if (handler->pid < 0)
return -1;
}
- if (handler->clone_flags & CLONE_NEWNET) {
+ if (handler->ns_clone_flags & CLONE_NEWNET) {
if (!lxc_list_empty(&conf->network)) {
/* Find gateway addresses from the link device, which is
}
/* Create a process in a new set of namespaces. */
- handler->on_clone_flags = handler->clone_flags;
- if (handler->clone_flags & CLONE_NEWUSER) {
+ handler->ns_on_clone_flags = handler->ns_clone_flags;
+ if (handler->ns_clone_flags & CLONE_NEWUSER) {
/* If CLONE_NEWUSER and CLONE_NEWNET was requested, we need to
* clone a new user namespace first and only later unshare our
* network namespace to ensure that network devices ownership is
* set up correctly.
*/
- handler->on_clone_flags &= ~CLONE_NEWNET;
+ handler->ns_on_clone_flags &= ~CLONE_NEWNET;
}
/* The cgroup namespace gets unshare()ed not clone()ed. */
- handler->on_clone_flags &= ~CLONE_NEWCGROUP;
+ handler->ns_on_clone_flags &= ~CLONE_NEWCGROUP;
if (share_ns) {
pid_t attacher_pid;
}
} else {
handler->pid = lxc_raw_clone_cb(do_start, handler,
- handler->on_clone_flags);
+ handler->ns_on_clone_flags);
}
if (handler->pid < 0) {
SYSERROR(LXC_CLONE_ERROR);
TRACE("Cloned child process %d", handler->pid);
for (i = 0; i < LXC_NS_MAX; i++)
- if (handler->on_clone_flags & ns_info[i].clone_flag)
+ if (handler->ns_on_clone_flags & ns_info[i].clone_flag)
INFO("Cloned %s", ns_info[i].flag_name);
- if (!lxc_preserve_namespaces(handler, handler->on_clone_flags, handler->pid)) {
+ if (!lxc_preserve_namespaces(handler, handler->ns_on_clone_flags, handler->pid)) {
ERROR("Failed to preserve cloned namespaces for lxc.hook.stop");
goto out_delete_net;
}
DEBUG("Preserved net namespace via fd %d", ret);
/* Create the network configuration. */
- if (handler->clone_flags & CLONE_NEWNET) {
+ if (handler->ns_clone_flags & CLONE_NEWNET) {
ret = lxc_network_move_created_netdev_priv(handler->lxcpath,
handler->name,
&conf->network,
cgroup_disconnect();
cgroups_connected = false;
- if (handler->clone_flags & CLONE_NEWCGROUP) {
+ if (handler->ns_clone_flags & CLONE_NEWCGROUP) {
/* Now we're ready to preserve the cgroup namespace */
ret = lxc_preserve_ns(handler->pid, "cgroup");
if (ret < 0) {
if (cgroups_connected)
cgroup_disconnect();
- if (handler->clone_flags & CLONE_NEWNET)
+ if (handler->ns_clone_flags & CLONE_NEWNET)
lxc_delete_network(handler);
out_abort: