Commit 21a2e2b3 authored by Colin Walters's avatar Colin Walters

Use MS_MOVE of / rather than chroot()

chroot() breaks some tools that expect / to be an actual mount point.
Doing namespace manipulation is cleaner than chroot().

See http://lists.freedesktop.org/archives/systemd-devel/2012-September/006703.html
"[systemd-devel] OSTree mount integration"
parent 515c7144
......@@ -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");
......
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