OSDN Git Service

70c8fe3f5af8054e3a827b4d1a63c8c0a12f9a03
[linuxjm/LDP_man-pages.git] / release / 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 .TH UNSHARE 2 2012\-12\-31 Linux "Linux Programmer's Manual"
26 .SH 名前
27 unshare \- プロセス実行コンテキストの一部を分離する
28 .SH 書式
29 .nf
30 .\" Actually _BSD_SOURCE || _SVID_SOURCE
31 .\" FIXME See http://sources.redhat.com/bugzilla/show_bug.cgi?id=4749
32 \fB#define _GNU_SOURCE\fP             /* feature_test_macros(7) 参照 */
33 \fB#include <sched.h>\fP
34 .sp
35 \fBint unshare(int \fP\fIflags\fP\fB);\fP
36 .fi
37 .SH 説明
38 \fBunshare\fP()  を使うと、プロセスは他のプロセスと現在共有している 実行コンテキストの一部を分離することができる。
39 実行コンテキストの一部、たとえばマウント名前空間 (mount namespace)  などは、新しいプロセスを \fBfork\fP(2)  または
40 \fBvfork\fP(2)  を使って生成したときに、暗黙のうちに共有される。 一方、仮想メモリなどは、 \fBclone\fP(2)
41 を使ってプロセスを生成するときに、明示的に共有することを要求できる。
42
43 \fBunshare\fP()  の主な利用法は、プロセスが新しいプロセスを生成することなく、 共有実行コンテキストを制御することである。
44
45 \fIflags\fP 引き数はビットマスクであり、 実行コンテキストのどの部分の共有を解除するかを表す。 この引き数は、以下の定数の 0 個以上の OR
46 で指定する:
47 .TP 
48 \fBCLONE_FILES\fP
49 \fBclone\fP(2)  \fBCLONE_FILES\fP フラグの効果を取り消す。 ファイルディスクリプタテーブルを共有させず、
50 呼び出し元プロセスは他のプロセスとファイルディスクリプタを共有しなくなる。
51 .TP 
52 \fBCLONE_FS\fP
53 Reverse the effect of the \fBclone\fP(2)  \fBCLONE_FS\fP flag.  Unshare file
54 system attributes, so that the calling process no longer shares its root
55 directory (\fBchroot\fP(2)), current directory (\fBchdir\fP(2)), or umask
56 (\fBumask\fP(2))  attributes with any other process.
57 .TP 
58 \fBCLONE_NEWIPC\fP (Linux 2.6.19 以降)
59 このフラグは \fBclone\fP(2) \fBCLONE_NEWIPC\fP フラグと同じ効果を持つ。
60 System V IPC 名前空間を共有せず、呼び出し元プロセスは 他のプロセスとは
61 共有しない固有の System V IPC 名前空間のコピーを持つ。 このフラグを指定
62 すると、 \fBCLONE_SYSVSEM\fP も暗黙のうちに指定される。 \fBCLONE_NEWIPC\fP を
63 使用するには \fBCAP_SYS_ADMIN\fP ケーパビリティが必要である。
64 .TP 
65 \fBCLONE_NEWNET\fP (Linux 2.6.24 以降)
66 This flag has the same effect as the \fBclone\fP(2)  \fBCLONE_NEWNET\fP flag.
67 Unshare the network namespace, so that the calling process is moved into a
68 new network namespace which is not shared with any previously existing
69 process.  Use of \fBCLONE_NEWNET\fP requires the \fBCAP_SYS_ADMIN\fP capability.
70 .TP 
71 \fBCLONE_NEWNS\fP
72 .\" These flag name are inconsistent:
73 .\" CLONE_NEWNS does the same thing in clone(), but CLONE_VM,
74 .\" CLONE_FS, and CLONE_FILES reverse the action of the clone()
75 .\" flags of the same name.
76 このフラグは \fBclone\fP(2) \fBCLONE_NEWNS\fP フラグと同じ効果を持つ。 マウン
77 ト名前空間を共有せず、呼び出し元プロセスは 他のプロセスとは共有しない固
78 有の名前空間のコピーを持つ。 このフラグを指定すると、 \fBCLONE_FS\fP も暗
79 黙のうちに指定される。 \fBCLONE_NEWNS\fP を使用するには \fBCAP_SYS_ADMIN\fP
80 ケーパビリティが必要である。
81 .TP 
82 \fBCLONE_NEWUTS\fP (Linux 2.6.19 以降)
83 このフラグは \fBclone\fP(2) \fBCLONE_NEWUTS\fP フラグと同じ効果を持つ。 UTS
84 IPC 名前空間を共有せず、呼び出し元プロセスは他のプロセスとは共有しない
85 固有の UTS IPC 名前空間のコピーを持つ。 このフラグを指定すると、
86 \fBCLONE_FS\fP も暗黙のうちに指定される。\fBCLONE_NEWUTS\fP を使用するには
87 \fBCAP_SYS_ADMIN\fP ケーパビリティが必要である。
88 .TP 
89 \fBCLONE_SYSVSEM\fP (Linux 2.6.26 以降)
90 .\" commit 9edff4ab1f8d82675277a04e359d0ed8bf14a7b7
91 .\" As at 2.6.16, the following forced implications also apply,
92 .\" although the relevant flags are not yet implemented.
93 .\" If CLONE_THREAD is set force CLONE_VM.
94 .\" If CLONE_VM is set, force CLONE_SIGHAND.
95 .\" CLONE_NEWNSIf CLONE_SIGHAND is set and signals are also being shared
96 .\" (i.e., current->signal->count > 1), force CLONE_THREAD.
97 .\"
98 .\" FIXME . CLONE_VM is not (yet, as at 2.6.16) implemented.
99 .\" .TP
100 .\" .B CLONE_VM
101 .\" Reverse the effect of the
102 .\" .BR clone (2)
103 .\" .B CLONE_VM
104 .\" flag.
105 .\" .RB ( CLONE_VM
106 .\" is also implicitly set by
107 .\" .BR vfork (2),
108 .\" and can be reversed using this
109 .\" .BR unshare ()
110 .\" flag.)
111 .\" Unshare virtual memory, so that the calling process no
112 .\" longer shares its virtual address space with any other process.
113 このフラグは \fBclone\fP(2) \fBCLONE_SYSVSEM\fP フラグの効果を逆転させる。
114 System V セマフォのアンドゥ値を共有せず、呼び出し元プロセスは 他のプロ
115 セスとは共有しない固有のコピーを持つ。\fBCLONE_SYSVSEM\fP を使用するには
116 \fBCAP_SYS_ADMIN\fP ケーパビリティが必要である。
117 .PP
118 \fIflags\fP に 0 が指定された場合、 \fBunshare\fP()  は何も行わないので、
119 呼び出し元プロセスの実行コンテキストは、何も変更されない。
120 .SH 返り値
121 成功した場合は 0 が返される。 失敗した場合は \-1 が返されて、 \fIerrno\fP にはエラーを示す値が設定される。
122 .SH エラー
123 .TP 
124 \fBEINVAL\fP
125 \fIflags\fP に不正なビットが指定された。
126 .TP 
127 \fBENOMEM\fP
128 呼び出し元のコンテキストのうち共有を解除する必要がある部分をコピーするために、 十分なメモリが確保できなかった。
129 .TP 
130 \fBEPERM\fP
131 呼び出し元プロセスはこの操作を行うのに必要な特権を持っていなかった。
132 .SH バージョン
133 \fBunshare\fP()  システムコールは Linux カーネル 2.6.16 で追加された。
134 .SH 準拠
135 \fBunshare\fP()  システムコールは Linux 固有である。
136 .SH 注意
137 .\" FIXME all of the following needs to be reviewed for the current kernel
138 .\" However, we can do unshare(CLONE_SIGHAND) if CLONE_SIGHAND
139 .\" was not specified when doing clone(); i.e., unsharing
140 .\" signal handlers is permitted if we are not actually
141 .\" sharing signal handlers.   mtk
142 .\" However, we can do unshare(CLONE_VM) if CLONE_VM
143 .\" was not specified when doing clone(); i.e., unsharing
144 .\" virtual memory is permitted if we are not actually
145 .\" sharing virtual memory.   mtk
146 .\"
147 .\"9) Future Work
148 .\"--------------
149 .\"The current implementation of unshare does not allow unsharing of
150 .\"signals and signal handlers. Signals are complex to begin with and
151 .\"to unshare signals and/or signal handlers of a currently running
152 .\"process is even more complex. If in the future there is a specific
153 .\"need to allow unsharing of signals and/or signal handlers, it can
154 .\"be incrementally added to unshare without affecting legacy
155 .\"applications using unshare.
156 .\"
157 Not all of the process attributes that can be shared when a new process is
158 created using \fBclone\fP(2)  can be unshared using \fBunshare\fP().  In
159 particular, as at kernel 3.8, \fBunshare\fP()  does not implement flags that
160 reverse the effects of \fBCLONE_SIGHAND\fP, \fBCLONE_THREAD\fP, or \fBCLONE_VM\fP.
161 Such functionality may be added in the future, if required.
162 .SH 関連項目
163 \fBclone\fP(2), \fBfork\fP(2), \fBkcmp\fP(2), \fBsetns\fP(2), \fBvfork\fP(2)
164
165 Linux カーネルソース内の \fIDocumentation/unshare.txt\fP
166 .SH この文書について
167 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.50 の一部
168 である。プロジェクトの説明とバグ報告に関する情報は
169 http://www.kernel.org/doc/man\-pages/ に書かれている。