int ipc_sockets[2];
int procfd;
signed long personality;
+ bool unshare_cgns = false;
if (!options)
options = &attach_static_default_options;
rexit(-1);
}
+ if (options->attach_flags & LXC_ATTACH_MOVE_TO_CGROUP && cgns_supported())
+ unshare_cgns = true;
+
procfd = open("/proc", O_DIRECTORY | O_RDONLY);
if (procfd < 0) {
SYSERROR("Unable to open /proc");
WARN("could not change directory to '%s'", new_cwd);
free(cwd);
- if (options->attach_flags & LXC_ATTACH_MOVE_TO_CGROUP && cgns_supported()) {
+ if (unshare_cgns) {
if (unshare(CLONE_NEWCGROUP) != 0) {
SYSERROR("cgroupns unshare: permission denied");
rexit(-1);
}
+ INFO("Unshared cgroup namespace");
}
/* now create the real child process */