Is it possible to exit the chroot(2) environment?

Yuri yuri at rawbw.com
Sun Sep 27 18:29:59 UTC 2020


This line 
https://github.com/rpm-software-management/rpm/blob/master/lib/rpmchroot.c#L155 
calls chroot(".") in order to exit from the chroot environment.

It apparently succeeds on Linux (this is rpm), but it fails on FreeBSD 
with "Operation not permitted", while executed under sudo.


The chroot(2) man page doesn't mention anything about exiting the chroot 
environment.


Does chroot(2) behave differently on Linux and FreeBSD, and chroot(".") 
is a valid way to exit on Linux and not on FreeBSD? Or what is going on 
here?


I wish somebody familiar with chroot add this information into the 
chroot(2) man page.


Thank you,

Yuri




More information about the freebsd-hackers mailing list