Re: CLONE_NEWNS and bind mounts to make "chroot" jail

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Leibowitz, Michael
Date: Tuesday, March 4, 2008 - 11:23 pm

I'm not 100% sure if this is what you meant, but I did get the following
to work:=20

chdir("/jail");=20
unshare(CLONE_NEWNS);
mount("/jail", "/jail", NULL, MS_BIND, NULL);
pivot_root("/jail", "/jail/old_root");
chdir("/");
mount("/old_root/bin", "bin", NULL, MS_BIND, NULL);
mount("/old_root/usr", "usr", NULL, MS_BIND, NULL);
mount("/old_root/lib", "lib", NULL, MS_BIND, NULL);
umount2("/old_root", MNT_DETACH);
exec("/busybox");

Thanks for the help. =20

On Tue, 2008-03-04 at 15:45 -0600, serge@hallyn.com wrote:

--=20
Michael Leibowitz <michael.leibowitz@intel.com>
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
CLONE_NEWNS and bind mounts to make &quot;chroot&quot; jail, Leibowitz, Michael, (Sat Mar 1, 10:05 am)
RE: CLONE_NEWNS and bind mounts to make &quot;chroot&quot; jail, Leibowitz, Michael, (Sun Mar 2, 11:56 pm)
Re: CLONE_NEWNS and bind mounts to make "chroot" jail, Leibowitz, Michael, (Tue Mar 4, 11:23 pm)