OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / original / 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@gmail.com>
32 .\"
33 .TH CHROOT 2 2008-06-23 "Linux" "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 of the calling process to that specified in
43 .IR path .
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.
46
47 Only a privileged process (Linux: one with the
48 .B CAP_SYS_CHROOT
49 capability) may call
50 .BR chroot ().
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 \(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"
59 by doing:
60 .nf
61
62     mkdir foo; chroot foo; cd ..
63 .fi
64
65 This call does not close open file descriptors, and such file
66 descriptors may allow access to files outside the chroot tree.
67 .SH "RETURN VALUE"
68 On success, zero is returned.
69 On error, \-1 is returned, and
70 .I errno
71 is set appropriately.
72 .SH ERRORS
73 Depending on the file system, other errors can be returned.
74 The more general errors are listed below:
75 .TP
76 .B EACCES
77 Search permission is denied on a component of the path prefix.
78 (See also
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?
82 .TP
83 .B EFAULT
84 .I path
85 points outside your accessible address space.
86 .TP
87 .B EIO
88 An I/O error occurred.
89 .TP
90 .B ELOOP
91 Too many symbolic links were encountered in resolving
92 .IR path .
93 .TP
94 .B ENAMETOOLONG
95 .I path
96 is too long.
97 .TP
98 .B ENOENT
99 The file does not exist.
100 .TP
101 .B ENOMEM
102 Insufficient kernel memory was available.
103 .TP
104 .B ENOTDIR
105 A component of
106 .I path
107 is not a directory.
108 .TP
109 .B EPERM
110 The caller has insufficient privilege.
111 .SH "CONFORMING TO"
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.
116 .SH NOTES
117 A child process created via
118 .BR fork (2)
119 inherits its parent's root directory.
120 The root directory is left unchanged by
121 .BR execve (2).
122
123 FreeBSD has a stronger
124 .BR jail ()
125 system call.
126 .\" FIXME . eventually say something about containers,
127 .\" virtual servers, etc.?
128 .SH "SEE ALSO"
129 .BR chdir (2),
130 .BR path_resolution (7)