OSDN Git Service

49c9b981f321f13276f0a605e8d2ce6252d8c627
[linuxjm/LDP_man-pages.git] / draft / man2 / unshare.2
1 .\" Copyright (C) 2006, Janak Desai <janak@us.ibm.com>
2 .\" and Copyright (C) 2006, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
5 .\" Licensed under the GPL
6 .\" %%%LICENSE_END
7 .\"
8 .\" Patch Justification:
9 .\" unshare system call is needed to implement, using PAM,
10 .\" per-security_context and/or per-user namespace to provide
11 .\" polyinstantiated directories. Using unshare and bind mounts, a
12 .\" PAM module can create private namespace with appropriate
13 .\" directories(based on user's security context) bind mounted on
14 .\" public directories such as /tmp, thus providing an instance of
15 .\" /tmp that is based on user's security context. Without the
16 .\" unshare system call, namespace separation can only be achieved
17 .\" by clone, which would require porting and maintaining all commands
18 .\" such as login, and su, that establish a user session.
19 .\"
20 .\"*******************************************************************
21 .\"
22 .\" This file was generated with po4a. Translate the source file.
23 .\"
24 .\"*******************************************************************
25 .\"
26 .\" Japanese Version Copyright (c) 2006 Yuichi SATO
27 .\"         all rights reserved.
28 .\" Translated 2006-08-10 by Yuichi SATO <ysato444@yahoo.co.jp>, LDP v2.36
29 .\" Updated 2012-05-08, Akihiro MOTOKI <amotoki@gmail.com>
30 .\" Updated 2013-03-26, Akihiro MOTOKI <amotoki@gmail.com>
31 .\" Updated 2013-05-06, Akihiro MOTOKI <amotoki@gmail.com>
32 .\"
33 .TH UNSHARE 2 2013\-04\-17 Linux "Linux Programmer's Manual"
34 .SH 名前
35 unshare \- プロセス実行コンテキストの一部を分離する
36 .SH 書式
37 .nf
38 \fB#include <sched.h>\fP
39 .sp
40 \fBint unshare(int \fP\fIflags\fP\fB);\fP
41 .fi
42 .sp
43 .in -4n
44 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
45 .in
46 .sp
47 \fBunshare\fP():
48 .ad l
49 .RS 4
50 .PD 0
51 .TP  4
52 glibc 2.14 以降:
53 _GNU_SOURCE
54 .TP  4
55 .\" FIXME See http://sources.redhat.com/bugzilla/show_bug.cgi?id=4749
56 glibc 2.14 より前:
57 _BSD_SOURCE || _SVID_SOURCE
58     /* _GNU_SOURCE も定義される */
59 .PD
60 .RE
61 .ad b
62 .SH 説明
63 \fBunshare\fP()  を使うと、プロセスは他のプロセスと現在共有している 実行コンテキストの一部を分離することができる。
64 実行コンテキストの一部、たとえばマウント名前空間 (mount namespace)  などは、新しいプロセスを \fBfork\fP(2)  または
65 \fBvfork\fP(2)  を使って生成したときに、暗黙のうちに共有される。 一方、仮想メモリなどは、 \fBclone\fP(2)
66 を使ってプロセスを生成するときに、明示的に共有することを要求できる。
67
68 \fBunshare\fP()  の主な利用法は、プロセスが新しいプロセスを生成することなく、 共有実行コンテキストを制御することである。
69
70 \fIflags\fP 引き数はビットマスクであり、 実行コンテキストのどの部分の共有を解除するかを表す。 この引き数は、以下の定数の 0 個以上の OR
71 で指定する:
72 .TP 
73 \fBCLONE_FILES\fP
74 \fBclone\fP(2)  \fBCLONE_FILES\fP フラグの効果を取り消す。 ファイルディスクリプタテーブルを共有させず、
75 呼び出し元プロセスは他のプロセスとファイルディスクリプタを共有しなくなる。
76 .TP 
77 \fBCLONE_FS\fP
78 Reverse the effect of the \fBclone\fP(2)  \fBCLONE_FS\fP flag.  Unshare filesystem
79 attributes, so that the calling process no longer shares its root directory
80 (\fBchroot\fP(2)), current directory (\fBchdir\fP(2)), or umask (\fBumask\fP(2))
81 attributes with any other process.
82 .TP 
83 \fBCLONE_NEWIPC\fP (Linux 2.6.19 以降)
84 このフラグは \fBclone\fP(2) \fBCLONE_NEWIPC\fP フラグと同じ効果を持つ。
85 System V IPC 名前空間を共有せず、呼び出し元プロセスは 他のプロセスとは
86 共有しない固有の System V IPC 名前空間のコピーを持つ。 このフラグを指定
87 すると、 \fBCLONE_SYSVSEM\fP も暗黙のうちに指定される。 \fBCLONE_NEWIPC\fP を
88 使用するには \fBCAP_SYS_ADMIN\fP ケーパビリティが必要である。
89 .TP 
90 \fBCLONE_NEWNET\fP (Linux 2.6.24 以降)
91 このフラグは \fBclone\fP(2) \fBCLONE_NEWNET\fP フラグと同じ効果を持つ。ネット
92 ワーク名前空間を共有せず、呼び出し元プロセスは他のプロセスとは共有しな
93 い固有のネットワーク名前空間のコピーを持つ。\fBCLONE_NEWNET\fP を使用する
94 には \fBCAP_SYS_ADMIN\fP ケーパビリティが必要である。
95 .TP 
96 \fBCLONE_NEWNS\fP
97 .\" These flag name are inconsistent:
98 .\" CLONE_NEWNS does the same thing in clone(), but CLONE_VM,
99 .\" CLONE_FS, and CLONE_FILES reverse the action of the clone()
100 .\" flags of the same name.
101 このフラグは \fBclone\fP(2) \fBCLONE_NEWNS\fP フラグと同じ効果を持つ。 マウン
102 ト名前空間を共有せず、呼び出し元プロセスは 他のプロセスとは共有しない固
103 有の名前空間のコピーを持つ。 このフラグを指定すると、 \fBCLONE_FS\fP も暗
104 黙のうちに指定される。 \fBCLONE_NEWNS\fP を使用するには \fBCAP_SYS_ADMIN\fP
105 ケーパビリティが必要である。
106 .TP 
107 \fBCLONE_NEWUTS\fP (Linux 2.6.19 以降)
108 このフラグは \fBclone\fP(2) \fBCLONE_NEWUTS\fP フラグと同じ効果を持つ。 UTS
109 IPC 名前空間を共有せず、呼び出し元プロセスは他のプロセスとは共有しない
110 固有の UTS IPC 名前空間のコピーを持つ。 このフラグを指定すると、
111 \fBCLONE_FS\fP も暗黙のうちに指定される。\fBCLONE_NEWUTS\fP を使用するには
112 \fBCAP_SYS_ADMIN\fP ケーパビリティが必要である。
113 .TP 
114 \fBCLONE_SYSVSEM\fP (Linux 2.6.26 以降)
115 .\" commit 9edff4ab1f8d82675277a04e359d0ed8bf14a7b7
116 .\" As at 2.6.16, the following forced implications also apply,
117 .\" although the relevant flags are not yet implemented.
118 .\" If CLONE_THREAD is set force CLONE_VM.
119 .\" If CLONE_VM is set, force CLONE_SIGHAND.
120 .\" CLONE_NEWNSIf CLONE_SIGHAND is set and signals are also being shared
121 .\" (i.e., current->signal->count > 1), force CLONE_THREAD.
122 .\"
123 .\" FIXME . CLONE_VM is not (yet, as at 2.6.16) implemented.
124 .\" .TP
125 .\" .B CLONE_VM
126 .\" Reverse the effect of the
127 .\" .BR clone (2)
128 .\" .B CLONE_VM
129 .\" flag.
130 .\" .RB ( CLONE_VM
131 .\" is also implicitly set by
132 .\" .BR vfork (2),
133 .\" and can be reversed using this
134 .\" .BR unshare ()
135 .\" flag.)
136 .\" Unshare virtual memory, so that the calling process no
137 .\" longer shares its virtual address space with any other process.
138 このフラグは \fBclone\fP(2) \fBCLONE_SYSVSEM\fP フラグの効果を逆転させる。
139 System V セマフォのアンドゥ値を共有せず、呼び出し元プロセスは 他のプロ
140 セスとは共有しない固有のコピーを持つ。\fBCLONE_SYSVSEM\fP を使用するには
141 \fBCAP_SYS_ADMIN\fP ケーパビリティが必要である。
142 .PP
143 \fIflags\fP に 0 が指定された場合、 \fBunshare\fP()  は何も行わないので、
144 呼び出し元プロセスの実行コンテキストは、何も変更されない。
145 .SH 返り値
146 成功した場合は 0 が返される。 失敗した場合は \-1 が返されて、 \fIerrno\fP にはエラーを示す値が設定される。
147 .SH エラー
148 .TP 
149 \fBEINVAL\fP
150 \fIflags\fP に不正なビットが指定された。
151 .TP 
152 \fBENOMEM\fP
153 呼び出し元のコンテキストのうち共有を解除する必要がある部分をコピーするために、 十分なメモリが確保できなかった。
154 .TP 
155 \fBEPERM\fP
156 呼び出し元プロセスはこの操作を行うのに必要な特権を持っていなかった。
157 .SH バージョン
158 \fBunshare\fP()  システムコールは Linux カーネル 2.6.16 で追加された。
159 .SH 準拠
160 \fBunshare\fP()  システムコールは Linux 固有である。
161 .SH 注意
162 .\" FIXME all of the following needs to be reviewed for the current kernel
163 .\" However, we can do unshare(CLONE_SIGHAND) if CLONE_SIGHAND
164 .\" was not specified when doing clone(); i.e., unsharing
165 .\" signal handlers is permitted if we are not actually
166 .\" sharing signal handlers.   mtk
167 .\" However, we can do unshare(CLONE_VM) if CLONE_VM
168 .\" was not specified when doing clone(); i.e., unsharing
169 .\" virtual memory is permitted if we are not actually
170 .\" sharing virtual memory.   mtk
171 .\"
172 .\"9) Future Work
173 .\"--------------
174 .\"The current implementation of unshare does not allow unsharing of
175 .\"signals and signal handlers. Signals are complex to begin with and
176 .\"to unshare signals and/or signal handlers of a currently running
177 .\"process is even more complex. If in the future there is a specific
178 .\"need to allow unsharing of signals and/or signal handlers, it can
179 .\"be incrementally added to unshare without affecting legacy
180 .\"applications using unshare.
181 .\"
182 \fBclone\fP(2)  で新しいプロセスを生成したときに共有される全てのプロセス属性を、 \fBunshare\fP()
183 によって共有の解除ができるわけではない。 特に、カーネル 3.8 時点では、 \fBunshare\fP()  に \fBCLONE_SIGHAND\fP,
184 \fBCLONE_THREAD\fP, \fBCLONE_VM\fP の効果を取り消すためのフラグが実装されていない。
185 これらの機能は、必要であれば将来追加されるかもしれない。
186 .SH 関連項目
187 \fBclone\fP(2), \fBfork\fP(2), \fBkcmp\fP(2), \fBsetns\fP(2), \fBvfork\fP(2)
188
189 Linux カーネルソース内の \fIDocumentation/unshare.txt\fP
190 .SH この文書について
191 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.54 の一部
192 である。プロジェクトの説明とバグ報告に関する情報は
193 http://www.kernel.org/doc/man\-pages/ に書かれている。