1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1994-08-21 by Michael Chastain <mec@shell.portal.com>
28 .\" Modified 1996-06-13 by aeb
29 .\" Modified 1996-11-06 by Eric S. Raymond <esr@thyrsus.com>
30 .\" Modified 1997-08-21 by Joseph S. Myers <jsm28@cam.ac.uk>
31 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
33 .TH CHROOT 2 2008-06-23 "Linux" "Linux Programmer's Manual"
35 chroot \- change root directory
37 .B #include <unistd.h>
39 .BI "int chroot(const char *" path );
42 changes the root directory of the calling process to that specified in
44 This directory will be used for pathnames beginning with \fI/\fP.
45 The root directory is inherited by all children of the calling process.
47 Only a privileged process (Linux: one with the
52 This call changes an ingredient in the pathname resolution process
53 and does nothing else.
55 This call does not change the current working directory,
56 so that after the call \(aq\fI.\fP\(aq can
57 be outside the tree rooted at \(aq\fI/\fP\(aq.
58 In particular, the superuser can escape from a "chroot jail"
62 mkdir foo; chroot foo; cd ..
65 This call does not close open file descriptors, and such file
66 descriptors may allow access to files outside the chroot tree.
68 On success, zero is returned.
69 On error, \-1 is returned, and
73 Depending on the file system, other errors can be returned.
74 The more general errors are listed below:
77 Search permission is denied on a component of the path prefix.
79 .BR path_resolution (7).)
80 .\" Also search permission is required on the final component,
81 .\" maybe just to guarantee that it is a directory?
85 points outside your accessible address space.
88 An I/O error occurred.
91 Too many symbolic links were encountered in resolving
99 The file does not exist.
102 Insufficient kernel memory was available.
110 The caller has insufficient privilege.
112 SVr4, 4.4BSD, SUSv2 (marked LEGACY).
113 This function is not part of POSIX.1-2001.
114 .\" SVr4 documents additional EINTR, ENOLINK and EMULTIHOP error conditions.
115 .\" X/OPEN does not document EIO, ENOMEM or EFAULT error conditions.
117 A child process created via
119 inherits its parent's root directory.
120 The root directory is left unchanged by
123 FreeBSD has a stronger
126 .\" FIXME . eventually say something about containers,
127 .\" virtual servers, etc.?
130 .BR path_resolution (7)