Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F164799286
D51703.id159647.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D51703.id159647.diff
View Options
Index: lib/libsys/chroot.2
===================================================================
--- lib/libsys/chroot.2
+++ lib/libsys/chroot.2
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd July 15, 2024
+.Dd August 2, 2025
.Dt CHROOT 2
.Os
.Sh NAME
@@ -61,7 +61,12 @@
.Fn chroot
has no effect on the process's current directory.
.Pp
-This call is restricted to the super-user.
+This call is restricted to the super-user, unless the
+.Ql security.bsd.unprivileged_chroot
+sysctl variable is set to 1
+and the process has enabled the
+.Dv PROC_NO_NEW_PRIVS_CTL
+.Xr procctl 2 .
.Pp
Depending on the setting of the
.Ql kern.chroot_allow_open_directories
@@ -106,28 +111,30 @@
.Sh ERRORS
The
.Fn chroot
-system call
+and
+.Fn fchroot
+system calls
will fail and the root directory will be unchanged if:
.Bl -tag -width Er
.It Bq Er ENOTDIR
-A component of the path name is not a directory.
+A component of the path name is not a directory
+or the file descriptor does not reference a directory.
.It Bq Er EPERM
-The effective user ID is not the super-user, or one or more
-filedescriptors are open directories.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named directory does not exist.
+The effective user ID is not the super-user and the
+.Ql security.bsd.unprivileged_chroot
+sysctl is 0.
+.It Bq Er EPERM
+The effective user ID is not the super-user and the
+process has not enabled the
+.Dv PROC_NO_NEW_PRIVS_CTL
+.Xr procctl 2 .
+.It Bq Er EPERM
+One or more filedescriptors are open directories and the
+.Ql kern.chroot_allow_open_directories
+sysctl is not set to permit this.
.It Bq Er EACCES
-Search permission is denied for any component of the path name.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EFAULT
-The
-.Fa dirname
-argument
-points outside the process's allocated address space.
+Search permission is denied for any component of the path name
+or the directory referenced by the file descriptor.
.It Bq Er EIO
An I/O error occurred while reading from or writing to the file system.
.It Bq Er EINTEGRITY
@@ -135,26 +142,32 @@
.El
.Pp
The
+.Fn chroot
+system call
+will fail and the root directory will be unchanged if:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The
+.Fa dirname
+argument points outside the process's allocated address space.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named directory does not exist.
+.El
+.Pp
+The
.Fn fchroot
system call
will fail and the root directory will be unchanged if:
.Bl -tag -width Er
-.It Bq Er EACCES
-Search permission is denied for the directory referenced by the
-file descriptor.
.It Bq Er EBADF
The argument
.Fa fd
is not a valid file descriptor.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er ENOTDIR
-The file descriptor does not reference a directory.
-.It Bq Er EPERM
-The effective user ID is not the super-user, or one or more
-filedescriptors are open directories.
.El
.Sh SEE ALSO
.Xr chdir 2 ,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 5, 2:47 AM (9 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35985492
Default Alt Text
D51703.id159647.diff (3 KB)
Attached To
Mode
D51703: chroot.2: Update errors and unprivileged use
Attached
Detach File
Event Timeline
Log In to Comment