Merge pull request #3897 from brauner/2021-07-05.fixes

lxc-unshare: fixes
This commit is contained in:
Stéphane Graber 2021-07-05 08:49:08 -04:00 committed by GitHub
commit 483f5b4f3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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();