]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/chroot.2
Change itacised function names and page xrefs to bold
[thirdparty/man-pages.git] / man2 / chroot.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
4 .\"
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.
8 .\"
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.
13 .\"
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
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
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@gmx.net>
32 .\"
33 .TH CHROOT 2 2004-06-23 "Linux 2.6.7" "Linux Programmer's Manual"
34 .SH NAME
35 chroot \- change root directory
36 .SH SYNOPSIS
37 .B #include <unistd.h>
38 .sp
39 .BI "int chroot(const char *" path );
40 .SH DESCRIPTION
41 .BR chroot ()
42 changes the root directory to that specified in
43 .IR path .
44 This directory will be used for path names beginning with /. The root
45 directory is inherited by all children of the current process.
46
47 Only a privileged process (Linux: one with the
48 .B CAP_SYS_CHROOT
49 capability) may call
50 .BR chroot (2).
51
52 This call changes an ingredient in the pathname resolution process
53 and does nothing else.
54
55 This call does not change the current working directory,
56 so that after the call `.' can be outside the tree rooted at `/'.
57 In particular, the superuser can escape from a `chroot jail'
58 by doing `mkdir foo; chroot foo; cd ..'.
59
60 This call does not close open file descriptors, and such file
61 descriptors may allow access to files outside the chroot tree.
62
63 .SH "RETURN VALUE"
64 On success, zero is returned. On error, \-1 is returned, and
65 .I errno
66 is set appropriately.
67 .SH ERRORS
68 Depending on the file system, other errors can be returned. The more
69 general errors are listed below:
70 .TP
71 .B EACCES
72 Search permission is denied on a component of the path prefix.
73 (See also
74 .BR path_resolution (2).)
75 .\" Also search permission is required on the final component,
76 .\" maybe just to guarantee that it is a directory?
77 .TP
78 .B EFAULT
79 .I path
80 points outside your accessible address space.
81 .TP
82 .B EIO
83 An I/O error occurred.
84 .TP
85 .B ELOOP
86 Too many symbolic links were encountered in resolving
87 .IR path .
88 .TP
89 .B ENAMETOOLONG
90 .I path
91 is too long.
92 .TP
93 .B ENOENT
94 The file does not exist.
95 .TP
96 .B ENOMEM
97 Insufficient kernel memory was available.
98 .TP
99 .B ENOTDIR
100 A component of
101 .I path
102 is not a directory.
103 .TP
104 .B EPERM
105 The caller has insufficient privilege.
106 .SH "CONFORMING TO"
107 SVr4, SVID, 4.4BSD, X/OPEN. This function is not part of POSIX.1.
108 SVr4 documents additional EINTR, ENOLINK and EMULTIHOP error conditions.
109 X/OPEN does not document EIO, ENOMEM or EFAULT error conditions.
110 This interface is marked as legacy by X/OPEN.
111 .SH NOTES
112 FreeBSD has a stronger
113 .BR jail ()
114 system call.
115 .SH "SEE ALSO"
116 .BR chdir (2),
117 .BR path_resolution (2)