Re: Glitch in sys_chroot()

=?ISO-8859-1?Q?Johan_Myr=E9en?= (jem@vistacom.fi)
Fri, 15 Nov 1996 08:17:04 +0200 (EET)


On Thu, 14 Nov 1996, Elliot Lee wrote:

> I still think that Linux should do the chdir() before the chroot(). If you
> can provide a reason why - besides "because that's the way it has been
> done" - I'd say you have a valid point. Until then I remain unconvinced,
> because of the possible security concerns from lax programming.

I don't think chroot() should do a chdir(). Why? Simply because chroot()
is chroot() and chdir() is chdir(). Keep it simple.

What if the current directory is, say, /usr/foo/bar/baz and you do a
chroot("/usr/foo"). Should the chroot() do a chdir("/usr/foo") then also?
I don't think so. This would definitely break a lot of old code.

The semantics could of course be changed so that the chdir() is done if
the current directory is outside the new root, but I think that would
unneccesarily complicate both the semantics and the code.

Johan Myreen
jem@iki.fi