OSDN Git Service

0d298e81b9e86008465228c07212d79c32f010a8
[linuxjm/LDP_man-pages.git] / release / man2 / chroot.2
1 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
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 .\"*******************************************************************
34 .\"
35 .\" This file was generated with po4a. Translate the source file.
36 .\"
37 .\"*******************************************************************
38 .\"
39 .\" Japanese Version Copyright (c) 1996 Yosiaki Yanagihara
40 .\"         all rights reserved.
41 .\" Translated Mon Jun 24 14:29:55 JST 1996
42 .\"         by Yosiaki Yanagihara <yosiaki@bsd2.kbnes.nec.co.jp>
43 .\" Modified Sat Dec 13 23:29:07 JST 1997
44 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
45 .\" Updated & Modified Fri 6 Apr 2001
46 .\"         by NAKANO Takeo <nakano@apm.seikei.ac.jp>
47 .\" Updated & Modified Thu Dec 23 10:04:20 JST 2004
48 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
49 .\"
50 .TH CHROOT 2 2010\-09\-20 Linux "Linux Programmer's Manual"
51 .SH 名前
52 chroot \- ルート・ディレクトリを変更する
53 .SH 書式
54 \fB#include <unistd.h>\fP
55 .sp
56 \fBint chroot(const char *\fP\fIpath\fP\fB);\fP
57 .sp
58 .in -4n
59 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
60 .in
61 .sp
62 \fBchroot\fP():
63 .ad l
64 .RS 4
65 .PD 0
66 .TP  4
67 glibc 2.2.2 以降:
68 .nf
69 _BSD_SOURCE ||
70     (_XOPEN_SOURCE\ >=\ 500 ||
71         _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
72     !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
73 .TP  4
74 .fi
75 glibc 2.2.2 より前: なし
76 .PD
77 .RE
78 .ad b
79 .SH 説明
80 \fBchroot\fP()  は、呼び出し元プロセスのルート・ディレクトリを \fIpath\fP で指定されたディレクトリに変更する。 このディレクトリ以下が
81 \fI/\fP から始まるパス名として使われる。 このルート・ディレクトリは呼び出し元のプロセスの全ての子プロセスに受け継がれる。
82
83 特権プロセス (Linux では、 \fBCAP_SYS_CHROOT\fP ケーパビリティを持つプロセス) のみが \fBchroot\fP()
84 を呼び出すことができる。
85
86 このコールはパス名解決の過程で構成要素を変更するのみで、 その他には何も行わない。
87
88 このコールは現在の作業ディレクトリ (working directory) を変更しない。 そのため、このコールの後に \(aq\fI.\fP\(aq が
89 \(aq\fI/\fP\(aq を 根とするツリーの外になる場合がある。 特に、スーパー・ユーザーは以下のようにすることで "chroot jail"
90 から逃げ出せてしまう。
91 .nf
92
93     mkdir foo; chroot foo; cd ..
94 .fi
95
96 このコールはオープンファイルディスクリプタをクローズしないので、 このようなファイルディスクリプタは chroot ツリーの外にある
97 ファイルにアクセスできる。
98 .SH 返り値
99 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。
100 .SH エラー
101 Depending on the filesystem, other errors can be returned.  The more general
102 errors are listed below:
103 .TP 
104 \fBEACCES\fP
105 .\" Also search permission is required on the final component,
106 .\" maybe just to guarantee that it is a directory?
107 パス名の構成要素に検索許可がない (\fBpath_resolution\fP(7)  も見よ)。
108 .TP 
109 \fBEFAULT\fP
110 \fIpath\fP がアクセスできるアドレス空間外を指している。
111 .TP 
112 \fBEIO\fP
113 I/O エラーが発生した。
114 .TP 
115 \fBELOOP\fP
116 \fIpath\fP を解決する際に遭遇したシンボリック・リンクが多過ぎる。
117 .TP 
118 \fBENAMETOOLONG\fP
119 \fIpath\fP が長過ぎる。
120 .TP 
121 \fBENOENT\fP
122 ファイルが存在しない。
123 .TP 
124 \fBENOMEM\fP
125 カーネルに十分なメモリがない。
126 .TP 
127 \fBENOTDIR\fP
128 \fIpath\fP の構成要素がディレクトリではない。
129 .TP 
130 \fBEPERM\fP
131 呼び出し側に十分な特権がない。
132 .SH 準拠
133 .\" SVr4 documents additional EINTR, ENOLINK and EMULTIHOP error conditions.
134 .\" X/OPEN does not document EIO, ENOMEM or EFAULT error conditions.
135 SVr4, 4.4BSD, SUSv2 (但し、SUSv2 では過去の名残とされている)。 この関数は POSIX.1\-2001 にはない。
136 .SH 注意
137 \fBfork\fP(2)  で作成された子プロセスは、 親プロセスのルート・ディレクトリを継承する。 \fBexecve\fP(2)
138 の場合も、ルート・ディレクトリは変更されない。
139
140 .\" FIXME . eventually say something about containers,
141 .\" virtual servers, etc.?
142 FreeBSD にはより強力な \fBjail\fP()  システムコールがある。
143 .SH 関連項目
144 \fBchdir\fP(2), \fBpath_resolution\fP(7)
145 .SH この文書について
146 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.54 の一部
147 である。プロジェクトの説明とバグ報告に関する情報は
148 http://www.kernel.org/doc/man\-pages/ に書かれている。