OSDN Git Service

228755bcc7a8f859b995e44d17738e1a0b4029da
[linuxjm/LDP_man-pages.git] / draft / 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 .TH CHROOT 2 2010\-09\-20 Linux "Linux Programmer's Manual"
39 .SH 名前
40 chroot \- ルート・ディレクトリを変更する
41 .SH 書式
42 \fB#include <unistd.h>\fP
43 .sp
44 \fBint chroot(const char *\fP\fIpath\fP\fB);\fP
45 .sp
46 .in -4n
47 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
48 .in
49 .sp
50 \fBchroot\fP():
51 .ad l
52 .RS 4
53 .PD 0
54 .TP  4
55 glibc 2.2.2 以降:
56 .nf
57 _BSD_SOURCE ||
58     (_XOPEN_SOURCE\ >=\ 500 ||
59         _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
60     !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
61 .TP  4
62 .fi
63 glibc 2.2.2 より前: なし
64 .PD
65 .RE
66 .ad b
67 .SH 説明
68 \fBchroot\fP()  は、呼び出し元プロセスのルート・ディレクトリを \fIpath\fP で指定されたディレクトリに変更する。 このディレクトリ以下が
69 \fI/\fP から始まるパス名として使われる。 このルート・ディレクトリは呼び出し元のプロセスの全ての子プロセスに受け継がれる。
70
71 特権プロセス (Linux では、 \fBCAP_SYS_CHROOT\fP ケーパビリティを持つプロセス) のみが \fBchroot\fP()
72 を呼び出すことができる。
73
74 このコールはパス名解決の過程で構成要素を変更するのみで、 その他には何も行わない。
75
76 このコールは現在の作業ディレクトリ (working directory) を変更しない。 そのため、このコールの後に \(aq\fI.\fP\(aq が
77 \(aq\fI/\fP\(aq を 根とするツリーの外になる場合がある。 特に、スーパー・ユーザーは以下のようにすることで "chroot jail"
78 から逃げ出せてしまう。
79 .nf
80
81     mkdir foo; chroot foo; cd ..
82 .fi
83
84 このコールはオープンファイルディスクリプタをクローズしないので、 このようなファイルディスクリプタは chroot ツリーの外にある
85 ファイルにアクセスできる。
86 .SH 返り値
87 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。
88 .SH エラー
89 ファイルシステムによっては他のエラーが返される事がある。 一般的なエラーを以下に挙げる:
90 .TP 
91 \fBEACCES\fP
92 .\" Also search permission is required on the final component,
93 .\" maybe just to guarantee that it is a directory?
94 パス名の構成要素に検索許可がない (\fBpath_resolution\fP(7)  も見よ)。
95 .TP 
96 \fBEFAULT\fP
97 \fIpath\fP がアクセスできるアドレス空間外を指している。
98 .TP 
99 \fBEIO\fP
100 I/O エラーが発生した。
101 .TP 
102 \fBELOOP\fP
103 \fIpath\fP を解決する際に遭遇したシンボリック・リンクが多過ぎる。
104 .TP 
105 \fBENAMETOOLONG\fP
106 \fIpath\fP が長過ぎる。
107 .TP 
108 \fBENOENT\fP
109 ファイルが存在しない。
110 .TP 
111 \fBENOMEM\fP
112 カーネルに十分なメモリがない。
113 .TP 
114 \fBENOTDIR\fP
115 \fIpath\fP の構成要素がディレクトリではない。
116 .TP 
117 \fBEPERM\fP
118 呼び出し側に十分な特権がない。
119 .SH 準拠
120 .\" SVr4 documents additional EINTR, ENOLINK and EMULTIHOP error conditions.
121 .\" X/OPEN does not document EIO, ENOMEM or EFAULT error conditions.
122 SVr4, 4.4BSD, SUSv2 (但し、SUSv2 では過去の名残とされている)。 この関数は POSIX.1\-2001 にはない。
123 .SH 注意
124 \fBfork\fP(2)  で作成された子プロセスは、 親プロセスのルート・ディレクトリを継承する。 \fBexecve\fP(2)
125 の場合も、ルート・ディレクトリは変更されない。
126
127 .\" FIXME . eventually say something about containers,
128 .\" virtual servers, etc.?
129 FreeBSD にはより強力な \fBjail\fP()  システムコールがある。
130 .SH 関連項目
131 \fBchdir\fP(2), \fBpath_resolution\fP(7)
132 .SH この文書について
133 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.52 の一部
134 である。プロジェクトの説明とバグ報告に関する情報は
135 http://www.kernel.org/doc/man\-pages/ に書かれている。