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 .\" 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>
44 .TH CHROOT 2 2008-06-23 "Linux" "Linux Programmer's Manual"
46 .\"O chroot \- change root directory
48 chroot \- ¥ë¡¼¥È¡¦¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ë
51 .B #include <unistd.h>
53 .BI "int chroot(const char *" path );
57 .\"O changes the root directory of the calling process to that specified in
59 .\"O This directory will be used for pathnames beginning with \fI/\fP.
60 .\"O The root directory is inherited by all children of the calling process.
62 ¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¥ë¡¼¥È¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ò
64 ¤Ç»ØÄꤵ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤ËÊѹ¹¤¹¤ë¡£
65 ¤³¤Î¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤¬ \fI/\fP ¤«¤é»Ï¤Þ¤ë¥Ñ¥¹Ì¾¤È¤·¤Æ»È¤ï¤ì¤ë¡£
66 ¤³¤Î¥ë¡¼¥È¡¦¥Ç¥£¥ì¥¯¥È¥ê¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÎÁ´¤Æ¤Î»Ò¥×¥í¥»¥¹¤Ë¼õ¤±·Ñ¤¬¤ì¤ë¡£
69 .\"O Only a privileged process (Linux: one with the
70 .\"O .B CAP_SYS_CHROOT
71 .\"O capability) may call
73 Æø¢¥×¥í¥»¥¹ (Linux ¤Ç¤Ï¡¢
75 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤Ä¥×¥í¥»¥¹) ¤Î¤ß¤¬
77 ¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤¤ë¡£
80 .\"O This call changes an ingredient in the pathname resolution process
81 .\"O and does nothing else.
82 ¤³¤Î¥³¡¼¥ë¤Ï¥Ñ¥¹Ì¾²ò·è¤Î²áÄø¤Ç¹½À®Í×ÁǤòÊѹ¹¤¹¤ë¤Î¤ß¤Ç¡¢
83 ¤½¤Î¾¤Ë¤Ï²¿¤â¹Ô¤ï¤Ê¤¤¡£
86 .\"O This call does not change the current working directory,
87 .\"O so that after the call \(aq\fI.\fP\(aq can
88 .\"O be outside the tree rooted at \(aq\fI/\fP\(aq.
89 .\"O In particular, the superuser can escape from a "chroot jail"
91 ¤³¤Î¥³¡¼¥ë¤Ï¸½ºß¤Îºî¶È¥Ç¥£¥ì¥¯¥È¥ê
92 (working directory) ¤òÊѹ¹¤·¤Ê¤¤¡£
93 ¤½¤Î¤¿¤á¡¢¤³¤Î¥³¡¼¥ë¤Î¸å¤Ë \(aq\fI.\fP\(aq ¤¬ \(aq\fI/\fP\(aq ¤ò
94 º¬¤È¤¹¤ë¥Ä¥ê¡¼¤Î³°¤Ë¤Ê¤ë¾ì¹ç¤¬¤¢¤ë¡£
95 Æäˡ¢¥¹¡¼¥Ñ¡¼¡¦¥æ¡¼¥¶¡¼¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤¹¤ë¤³¤È¤Ç
96 "chroot jail" ¤«¤éƨ¤²½Ð¤»¤Æ¤·¤Þ¤¦¡£
99 mkdir foo; chroot foo; cd ..
102 .\"O This call does not close open file descriptors, and such file
103 .\"O descriptors may allow access to files outside the chroot tree.
104 ¤³¤Î¥³¡¼¥ë¤Ï¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò¥¯¥í¡¼¥º¤·¤Ê¤¤¤Î¤Ç¡¢
105 ¤³¤Î¤è¤¦¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï chroot ¥Ä¥ê¡¼¤Î³°¤Ë¤¢¤ë
106 ¥Õ¥¡¥¤¥ë¤Ë¥¢¥¯¥»¥¹¤Ç¤¤ë¡£
107 .\"O .SH "RETURN VALUE"
109 .\"O On success, zero is returned.
110 .\"O On error, \-1 is returned, and
112 .\"O is set appropriately.
113 À®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤¹¡£
114 ¼ºÇÔ¤¹¤ë¤È \-1 ¤òÊÖ¤·¡¢
116 ¤ËŬÀÚ¤ÊÃͤòÀßÄꤹ¤ë¡£
119 .\"O Depending on the file system, other errors can be returned.
120 .\"O The more general errors are listed below:
121 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤Æ¤Ï¾¤Î¥¨¥é¡¼¤¬ÊÖ¤µ¤ì¤ë»ö¤¬¤¢¤ë¡£
122 °ìÈÌŪ¤Ê¥¨¥é¡¼¤ò°Ê²¼¤Ëµó¤²¤ë:
125 .\"O Search permission is denied on a component of the path prefix.
126 ¥Ñ¥¹Ì¾¤ÎÅÓÃæ¤Î¤É¤³¤«¤Ë¸¡º÷µö²Ä (search permission) ¤¬¤Ê¤¤¡£
128 .\"O .BR path_resolution (7).)
129 .RB ( path_resolution (7)
131 .\"O .\" Also search permission is required on the final component,
132 .\"O .\" maybe just to guarantee that it is a directory?
133 .\" ¥Ñ¥¹Ì¾¤ÎºÇ¸å¤Î¹½À®Í×ÁǤˤ⸡º÷µö²Ä¤¬É¬ÍפǤ¢¤ë¡£
134 .\" ¤ª¤½¤é¤¯¡¢¤½¤ì¤¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤¢¤ë¤³¤È¤òÊݾڤ¹¤ë¤¿¤á¤Ê¤Î¤«?
138 .\"O points outside your accessible address space.
140 ¤¬³ä¤êÅö¤Æ¤é¤ì¤¿¥¢¥É¥ì¥¹¶õ´Ö³°¤ò»Ø¤·¤Æ¤¤¤ë¡£
143 .\"O An I/O error occurred.
144 I/O ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¡£
147 .\"O Too many symbolic links were encountered in resolving
150 ¤ò²ò·è¤¹¤ëºÝ¤ËÁø¶ø¤·¤¿¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤¬Â¿²á¤®¤ë¡£
159 .\"O The file does not exist.
160 ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤¤¡£
163 .\"O Insufficient kernel memory was available.
164 ¥«¡¼¥Í¥ë¤Ë½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¡£
169 .\"O is not a directory.
171 ¤ÎÆâÍƤ¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ï¤Ê¤¤¡£
174 .\"O The caller has insufficient privilege.
175 ¸Æ¤Ó½Ð¤·Â¦¤Ë½½Ê¬¤ÊÆø¢¤¬¤Ê¤¤¡£
176 .\"O .SH "CONFORMING TO"
178 .\"O SVr4, 4.4BSD, SUSv2 (marked LEGACY).
179 .\"O This function is not part of POSIX.1-2001.
180 .\"O .\" SVr4 documents additional EINTR, ENOLINK and EMULTIHOP error conditions.
181 .\"O .\" X/OPEN does not document EIO, ENOMEM or EFAULT error conditions.
182 SVr4, 4.4BSD, SUSv2 (⤷¡¢SUSv2 ¤Ç¤Ï²áµî¤Î̾»Ä¤È¤µ¤ì¤Æ¤¤¤ë)¡£
183 ¤³¤Î´Ø¿ô¤Ï POSIX.1-2001 ¤Ë¤Ï¤Ê¤¤¡£
184 .\" SVr4 ¤Ë¤Ï¾¤Ë EINTR, ENOLINK, EMULTIHOP ¥¨¥é¡¼¾õÂ֤ˤĤ¤¤Æ¤Îµ½Ò¤¬¤¢¤ë¡£
185 .\" X/OPEN ¤Ë¤Ï EIO, ENOMEM, EFAULT ¥¨¥é¡¼¾õÂ֤ε½Ò¤Ï¤Ê¤¤¡£
188 .\"O A child process created via
190 .\"O inherits its parent's root directory.
191 .\"O The root directory is left unchanged by
194 ¤ÇºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¡¢
195 ¿Æ¥×¥í¥»¥¹¤Î¥ë¡¼¥È¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ò·Ñ¾µ¤¹¤ë¡£
197 ¤Î¾ì¹ç¤â¡¢¥ë¡¼¥È¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ÏÊѹ¹¤µ¤ì¤Ê¤¤¡£
199 .\"O FreeBSD has a stronger
202 FreeBSD ¤Ë¤Ï¤è¤ê¶¯ÎϤÊ
204 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬¤¢¤ë¡£
205 .\" FIXME . eventually say something about containers,
206 .\" virtual servers, etc.?
210 .BR path_resolution (7)