Commit 61eea63b authored by Colin Walters's avatar Colin Walters

Only MS_MOVE the root to / if the root isn't already /

Otherwise the MS_MOVE call aborts.
parent 21a2e2b3
......@@ -351,11 +351,15 @@ main (int argc,
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)");
/* Only move if we're not actually just using / */
if (strcmp (chroot_dir, "/") != 0)
{
if (mount (chroot_dir, "/", NULL, MS_MOVE, NULL) < 0)
fatal_errno ("mount (MS_MOVE)");
if (chroot (".") < 0)
fatal_errno ("chroot");
if (chroot (".") < 0)
fatal_errno ("chroot");
}
if (chdir (chdir_target) < 0)
fatal_errno ("chdir");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment