OSDN Git Service

d87bedccebcd552d62f0d06a4f018218cb045cd4
[linuxjm/LDP_man-pages.git] / draft / 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 .\" Japanese Version Copyright (c) 1996 Yosiaki Yanagihara
34 .\"         all rights reserved.
35 .\" Translated Mon Jun 24 14:29:55 JST 1996
36 .\"         by Yosiaki Yanagihara <yosiaki@bsd2.kbnes.nec.co.jp>
37 .\" Modified Sat Dec 13 23:29:07 JST 1997
38 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
39 .\" Updated & Modified Fri 6 Apr 2001
40 .\"         by NAKANO Takeo <nakano@apm.seikei.ac.jp>
41 .\" Updated & Modified Thu Dec 23 10:04:20 JST 2004
42 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
43 .\"
44 .TH CHROOT 2 2010-09-20 "Linux" "Linux Programmer's Manual"
45 .\"O .SH NAME
46 .\"O chroot \- change root directory
47 .SH Ì¾Á°
48 chroot \- ¥ë¡¼¥È¡¦¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ë
49 .\"O .SH SYNOPSIS
50 .SH ½ñ¼°
51 .B #include <unistd.h>
52 .sp
53 .BI "int chroot(const char *" path );
54 .sp
55 .in -4n
56 .\"O Feature Test Macro Requirements for glibc (see
57 .\"O .BR feature_test_macros (7)):
58 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
59 .RB ( feature_test_macros (7)
60 »²¾È):
61 .in
62 .sp
63 .BR chroot ():
64 .ad l
65 .RS 4
66 .PD 0
67 .TP 4
68 .\"O Since glibc 2.2.2:
69 glibc 2.2.2 °Ê¹ß:
70 .nf
71 _BSD_SOURCE ||
72     (_XOPEN_SOURCE\ >=\ 500 ||
73         _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
74     !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
75 .fi
76 .TP 4
77 .\"O Before glibc 2.2.2: none
78 glibc 2.2.2 ¤è¤êÁ°: ¤Ê¤·
79 .PD
80 .RE
81 .ad b
82 .\"O .SH DESCRIPTION
83 .SH ÀâÌÀ
84 .\"O .BR chroot ()
85 .\"O changes the root directory of the calling process to that specified in
86 .\"O .IR path .
87 .\"O This directory will be used for pathnames beginning with \fI/\fP.
88 .\"O The root directory is inherited by all children of the calling process.
89 .BR chroot ()
90 ¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¥ë¡¼¥È¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ò
91 .I path
92 ¤Ç»ØÄꤵ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤ËÊѹ¹¤¹¤ë¡£
93 ¤³¤Î¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤¬ \fI/\fP ¤«¤é»Ï¤Þ¤ë¥Ñ¥¹Ì¾¤È¤·¤Æ»È¤ï¤ì¤ë¡£
94 ¤³¤Î¥ë¡¼¥È¡¦¥Ç¥£¥ì¥¯¥È¥ê¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÎÁ´¤Æ¤Î»Ò¥×¥í¥»¥¹¤Ë¼õ¤±·Ñ¤¬¤ì¤ë¡£
95 .\"O 
96 .PP
97 .\"O Only a privileged process (Linux: one with the
98 .\"O .B CAP_SYS_CHROOT
99 .\"O capability) may call
100 .\"O .BR chroot ().
101 Æø¢¥×¥í¥»¥¹ (Linux ¤Ç¤Ï¡¢
102 .B CAP_SYS_CHROOT
103 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤Ä¥×¥í¥»¥¹) ¤Î¤ß¤¬
104 .BR chroot ()
105 ¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤­¤ë¡£
106 .\"O 
107 .PP
108 .\"O This call changes an ingredient in the pathname resolution process
109 .\"O and does nothing else.
110 ¤³¤Î¥³¡¼¥ë¤Ï¥Ñ¥¹Ì¾²ò·è¤Î²áÄø¤Ç¹½À®Í×ÁǤòÊѹ¹¤¹¤ë¤Î¤ß¤Ç¡¢
111 ¤½¤Î¾¤Ë¤Ï²¿¤â¹Ô¤ï¤Ê¤¤¡£
112 .\"O 
113 .PP
114 .\"O This call does not change the current working directory,
115 .\"O so that after the call \(aq\fI.\fP\(aq can
116 .\"O be outside the tree rooted at \(aq\fI/\fP\(aq.
117 .\"O In particular, the superuser can escape from a "chroot jail"
118 .\"O by doing:
119 ¤³¤Î¥³¡¼¥ë¤Ï¸½ºß¤Îºî¶È¥Ç¥£¥ì¥¯¥È¥ê
120 (working directory) ¤òÊѹ¹¤·¤Ê¤¤¡£
121 ¤½¤Î¤¿¤á¡¢¤³¤Î¥³¡¼¥ë¤Î¸å¤Ë \(aq\fI.\fP\(aq ¤¬ \(aq\fI/\fP\(aq ¤ò
122 º¬¤È¤¹¤ë¥Ä¥ê¡¼¤Î³°¤Ë¤Ê¤ë¾ì¹ç¤¬¤¢¤ë¡£
123 Æäˡ¢¥¹¡¼¥Ñ¡¼¡¦¥æ¡¼¥¶¡¼¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤¹¤ë¤³¤È¤Ç
124 "chroot jail" ¤«¤éƨ¤²½Ð¤»¤Æ¤·¤Þ¤¦¡£
125 .nf
126
127     mkdir foo; chroot foo; cd ..
128 .fi
129
130 .\"O This call does not close open file descriptors, and such file
131 .\"O descriptors may allow access to files outside the chroot tree.
132 ¤³¤Î¥³¡¼¥ë¤Ï¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò¥¯¥í¡¼¥º¤·¤Ê¤¤¤Î¤Ç¡¢
133 ¤³¤Î¤è¤¦¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï chroot ¥Ä¥ê¡¼¤Î³°¤Ë¤¢¤ë
134 ¥Õ¥¡¥¤¥ë¤Ë¥¢¥¯¥»¥¹¤Ç¤­¤ë¡£
135 .\"O .SH "RETURN VALUE"
136 .SH ÊÖ¤êÃÍ
137 .\"O On success, zero is returned.
138 .\"O On error, \-1 is returned, and
139 .\"O .I errno
140 .\"O is set appropriately.
141 À®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤¹¡£
142 ¼ºÇÔ¤¹¤ë¤È \-1 ¤òÊÖ¤·¡¢
143 .I errno
144 ¤ËŬÀÚ¤ÊÃͤòÀßÄꤹ¤ë¡£
145 .\"O .SH ERRORS
146 .SH ¥¨¥é¡¼
147 .\"O Depending on the file system, other errors can be returned.
148 .\"O The more general errors are listed below:
149 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤Æ¤Ï¾¤Î¥¨¥é¡¼¤¬ÊÖ¤µ¤ì¤ë»ö¤¬¤¢¤ë¡£
150 °ìÈÌŪ¤Ê¥¨¥é¡¼¤ò°Ê²¼¤Ëµó¤²¤ë:
151 .TP
152 .B EACCES
153 .\"O Search permission is denied on a component of the path prefix.
154 ¥Ñ¥¹Ì¾¤ÎÅÓÃæ¤Î¤É¤³¤«¤Ë¸¡º÷µö²Ä (search permission) ¤¬¤Ê¤¤¡£
155 .\"O (See also
156 .\"O .BR path_resolution (7).)
157 .RB ( path_resolution (7)
158 ¤â»²¾È¤¹¤ë¤³¤È¡£)
159 .\"O .\" Also search permission is required on the final component,
160 .\"O .\" maybe just to guarantee that it is a directory?
161 .\" ¥Ñ¥¹Ì¾¤ÎºÇ¸å¤Î¹½À®Í×ÁǤˤ⸡º÷µö²Ä¤¬É¬ÍפǤ¢¤ë¡£
162 .\" ¤ª¤½¤é¤¯¡¢¤½¤ì¤¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤¢¤ë¤³¤È¤òÊݾڤ¹¤ë¤¿¤á¤Ê¤Î¤«?
163 .TP
164 .B EFAULT
165 .\"O .I path
166 .\"O points outside your accessible address space.
167 .I path
168 ¤¬³ä¤êÅö¤Æ¤é¤ì¤¿¥¢¥É¥ì¥¹¶õ´Ö³°¤ò»Ø¤·¤Æ¤¤¤ë¡£
169 .TP
170 .B EIO
171 .\"O An I/O error occurred.
172 I/O ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¡£
173 .TP
174 .B ELOOP
175 .\"O Too many symbolic links were encountered in resolving
176 .\"O .IR path .
177 .I path
178 ¤ò²ò·è¤¹¤ëºÝ¤ËÁø¶ø¤·¤¿¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤¬Â¿²á¤®¤ë¡£
179 .TP
180 .B ENAMETOOLONG
181 .\"O .I path
182 .\"O is too long.
183 .I path
184 ¤¬Ä¹²á¤®¤ë¡£
185 .TP
186 .B ENOENT
187 .\"O The file does not exist.
188 ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤¤¡£
189 .TP
190 .B ENOMEM
191 .\"O Insufficient kernel memory was available.
192 ¥«¡¼¥Í¥ë¤Ë½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¡£
193 .TP
194 .B ENOTDIR
195 .\"O A component of
196 .\"O .I path
197 .\"O is not a directory.
198 .I path
199 ¤ÎÆâÍƤ¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ï¤Ê¤¤¡£
200 .TP
201 .B EPERM
202 .\"O The caller has insufficient privilege.
203 ¸Æ¤Ó½Ð¤·Â¦¤Ë½½Ê¬¤ÊÆø¢¤¬¤Ê¤¤¡£
204 .\"O .SH "CONFORMING TO"
205 .SH ½àµò
206 .\"O SVr4, 4.4BSD, SUSv2 (marked LEGACY).
207 .\"O This function is not part of POSIX.1-2001.
208 .\"O .\" SVr4 documents additional EINTR, ENOLINK and EMULTIHOP error conditions.
209 .\"O .\" X/OPEN does not document EIO, ENOMEM or EFAULT error conditions.
210 SVr4, 4.4BSD, SUSv2 (⤷¡¢SUSv2 ¤Ç¤Ï²áµî¤Î̾»Ä¤È¤µ¤ì¤Æ¤¤¤ë)¡£
211 ¤³¤Î´Ø¿ô¤Ï POSIX.1-2001 ¤Ë¤Ï¤Ê¤¤¡£
212 .\" SVr4 ¤Ë¤Ï¾¤Ë EINTR, ENOLINK, EMULTIHOP ¥¨¥é¡¼¾õÂ֤ˤĤ¤¤Æ¤Îµ­½Ò¤¬¤¢¤ë¡£
213 .\" X/OPEN ¤Ë¤Ï EIO, ENOMEM, EFAULT ¥¨¥é¡¼¾õÂ֤ε­½Ò¤Ï¤Ê¤¤¡£
214 .\"O .SH NOTES
215 .SH Ãí°Õ
216 .\"O A child process created via
217 .\"O .BR fork (2)
218 .\"O inherits its parent's root directory.
219 .\"O The root directory is left unchanged by
220 .\"O .BR execve (2).
221 .BR fork (2)
222 ¤ÇºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¡¢
223 ¿Æ¥×¥í¥»¥¹¤Î¥ë¡¼¥È¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ò·Ñ¾µ¤¹¤ë¡£
224 .BR execve (2)
225 ¤Î¾ì¹ç¤â¡¢¥ë¡¼¥È¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ÏÊѹ¹¤µ¤ì¤Ê¤¤¡£
226
227 .\"O FreeBSD has a stronger
228 .\"O .BR jail ()
229 .\"O system call.
230 FreeBSD ¤Ë¤Ï¤è¤ê¶¯ÎϤÊ
231 .BR jail ()
232 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬¤¢¤ë¡£
233 .\" FIXME . eventually say something about containers,
234 .\" virtual servers, etc.?
235 .\"O .SH "SEE ALSO"
236 .SH ´ØÏ¢¹àÌÜ
237 .BR chdir (2),
238 .BR path_resolution (7)