Is it possible to exit the chroot(2) environment?
Yuri
yuri at rawbw.com
Sun Sep 27 21:37:45 UTC 2020
On 2020-09-27 13:25, Kyle Evans wrote:
> +1. I think an additional sentence pointing out that that's the
> traditional behavior would outline that this is perhaps what's needed,
> maybe with a specific EPERM reference.
The fact that chroot(".") undoes the previous chroot(...) call should
also be documented, IMO. The current chroot(2) man page doesn't mention
this.
Also chroot apparently preserves the current working directory for the
purpose of chroot("."), but not for other purposes.
What if chdir(2) with the same string $OLD_WD is called in the chroot
environment with root in $ROOT_DIR, i.e. chroot($OLD_WD), and it
succeeds because there happens to be a directory with the same path
$OLD_WD in the chroot environment too, i.e. $CHROOT_DIR$OLD_WD is a
valid directory. Would chroot(".") then change root back to the original
directory $OLD_WD, or it would change it deeper into the root
environment directory: $CHROOT_DIR$OLD_WD ?
All this makes for a complex and potentially confusing behavior, which
should be documented, IMO.
Yuri
More information about the freebsd-hackers
mailing list