diff options
-rw-r--r-- | src/linux-user-chroot.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/linux-user-chroot.c b/src/linux-user-chroot.c index 217d651..82070b2 100644 --- a/src/linux-user-chroot.c +++ b/src/linux-user-chroot.c @@ -344,10 +344,19 @@ main (int argc, assert (0); free (dest); } - - /* Actually perform the chroot. */ - if (chroot (chroot_dir) < 0) + + if (chdir (chroot_dir) < 0) + fatal_errno ("chdir"); + + if (mount (chroot_dir, chroot_dir, NULL, MS_BIND | MS_PRIVATE, NULL) < 0) + fatal_errno ("mount (MS_BIND)"); + + if (mount (chroot_dir, "/", NULL, MS_MOVE, NULL) < 0) + fatal_errno ("mount (MS_MOVE)"); + + if (chroot (".") < 0) fatal_errno ("chroot"); + if (chdir (chdir_target) < 0) fatal_errno ("chdir"); |