diff --git a/src/lxc/tools/lxc_unshare.c b/src/lxc/tools/lxc_unshare.c index b4b073a02..a0ef5f618 100644 --- a/src/lxc/tools/lxc_unshare.c +++ b/src/lxc/tools/lxc_unshare.c @@ -246,8 +246,13 @@ static int do_start(void *arg) } } - if ((start_arg->flags & CLONE_NEWNS) && start_arg->want_default_mounts) - lxc_setup_fs(); + if (start_arg->flags & CLONE_NEWNS) { + if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0) < 0) + _exit(EXIT_FAILURE); + + if (start_arg->want_default_mounts) + lxc_setup_fs(); + } if ((start_arg->flags & CLONE_NEWUTS) && want_hostname) if (sethostname(want_hostname, strlen(want_hostname)) < 0) { @@ -411,7 +416,7 @@ int main(int argc, char *argv[]) if (lpid == 0) { char buf[256]; - ret = snprintf(buf, 256, "%d", lpid); + ret = snprintf(buf, 256, "%d", pid); if (ret < 0 || ret >= 256) _exit(EXIT_FAILURE); @@ -420,8 +425,7 @@ int main(int argc, char *argv[]) } if (wait_for_pid(lpid) != 0) - SYSERROR("Could not move interface \"%s\" into container %d", - ifname, lpid); + SYSERROR("Could not move interface \"%s\" into container %d", ifname, lpid); } free_ifname_list();