chroot()

guy at rlgvax.UUCP guy at rlgvax.UUCP
Mon Jul 11 06:17:51 AEST 1983


As an earlier poster said, both sides of this argument are correct.  A short
explanation of some other points:

	As far as 4.1BSD goes:  The code for chroot(), chdir(), and chdirec()
	(the underlying code of both) is character for character the same:
	ERGO, 4.1 does exactly the same.

But the code in namei() is different, and THAT is the code that interprets
pathnames.  All chdir(), chroot(), and chdirec() do is set an inode pointer
in your u-page; namei() is the routine that is affected by changing that
pointer.

	Summary:  REMEMBER that UNIX heirarchy reverse-links are implemented
	with pointers that turn the directed acyclic graph you think you see
	into a heavily-cyclic graph.  If you want to do this, I suppose that
	you could remove the ".." pointer in /usr/guests, but a lot of UNIX
	utilities are going to throw up their hands at that.

The fix in 4.1BSD and System III causes a dynamic reinterpretation of the ".."
link, so that the tree looks different to different processes.  The ".." link
should NOT be removed, as it will upset those utilities; the fix should be put
into namei() to reinterpret that link if it points above the fake root
directory.

Conclusion: on 4.1BSD and System III (and all later releases), feel free to
use chroot().  On V7, put in the fix I posted, and then feel free to use
chroot().  If you're running a UNIX-lookalike, make sure if it has chroot()
that the hole has been plugged.  If you wrote a UNIX-lookalike with chroot(),
plug the hole.

	Guy Harris
	{seismo,mcnc,we13,brl-bmd,allegra}!rlgvax!guy



More information about the Comp.unix.wizards mailing list