OSDN Git Service

6b3a1d8b2bcdf8c93315e28d1c9a4c8b5e6625ff
[linuxjm/LDP_man-pages.git] / draft / man2 / setuid.2
1 .\" Copyright (C), 1994, Graeme W. Wilford (Wilf).
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Fri Jul 29th 12:56:44 BST 1994  Wilf. <G.Wilford@ee.surrey.ac.uk>
24 .\" Changes inspired by patch from Richard Kettlewell
25 .\"   <richard@greenend.org.uk>, aeb 970616.
26 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
27 .\"     Added notes on capability requirements
28 .\"
29 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
30 .\"         all rights reserved.
31 .\" Translated Sat Mar  1 16:32:11 JST 1997
32 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
33 .\" Modified Sun Sep 28 20:26:49 JST 1997
34 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
35 .\" Updated & Modified Sat May 22 18:21:45 JST 2004
36 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
37 .\" Updated & Modified Wed Jan  5 00:51:28 JST 2005 by Yuichi SATO
38 .\" Updated 2010-04-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.24
39 .\"
40 .\"WORD:        identity                識別
41 .\"WORD:        effective user ID       実効ユーザーID
42 .\"WORD:        real user ID            実ユーザーID
43 .\"WORD:        saved user ID           保存ユーザーID
44 .\"WORD:        implement               実装
45 .\"WORD:        root                    ルート
46 .\"WORD:        super-user              スーパー・ユーザー
47 .\"
48 .TH SETUID 2 2010-02-21 "Linux" "Linux Programmer's Manual"
49 .\"O .SH NAME
50 .SH 名前
51 .\"O setuid \- set user identity
52 setuid \- ユーザー識別 (identity) を設定する
53 .\"O .SH SYNOPSIS
54 .SH 書式
55 .B #include <sys/types.h>
56 .br
57 .B #include <unistd.h>
58 .sp
59 .BI "int setuid(uid_t " uid );
60 .\"O .SH DESCRIPTION
61 .SH 説明
62 .\"O .BR setuid ()
63 .\"O sets the effective user ID of the calling process.
64 .\"O If the effective UID of the caller is root,
65 .\"O the real UID and saved set-user-ID are also set.
66 .BR setuid ()
67 は呼び出し元のプロセスの実効 (effective) ユーザー ID を設定する。
68 もし呼び出し元プロセスの実効 UID が root ならば、
69 実 (real) UID と保存 (saved) set-user-ID も設定される。
70 .PP
71 .\"O Under Linux,
72 .\"O .BR setuid ()
73 .\"O is implemented like the POSIX version with the
74 .\"O .B _POSIX_SAVED_IDS
75 .\"O feature.
76 .\"O This allows a set-user-ID (other than root) program to drop all of its user
77 .\"O privileges, do some un-privileged work, and then reengage the original
78 .\"O effective user ID in a secure manner.
79 Linux では、
80 .BR setuid ()
81
82 .B _POSIX_SAVED_IDS
83 をもった POSIX 版のように実装されている。
84 これは (ルート以外の) set-user-ID プログラムにそのユーザーの特権を
85 全て与え、特権の必要ない仕事をし、本来の実効ユーザー ID に
86 安全な方法で再び戻すことを許す。
87 .PP
88 .\"O If the user is root or the program is set-user-ID root, special care must be
89 .\"O taken.
90 .\"O The
91 .\"O .BR setuid ()
92 .\"O function checks the effective user ID of the caller and if it is
93 .\"O the superuser, all process-related user ID's are set to
94 .\"O .IR uid .
95 .\"O After this has occurred, it is impossible for the program to regain root
96 .\"O privileges.
97 ユーザーが root またはプログラムが root に set-user-ID されているならば、
98 特別の注意が払われる。
99 .BR setuid ()
100 関数は呼び出し者の実効ユーザー ID をチェックし、
101 それがスーパー・ユーザーならば、
102 プロセスに関連する全てのユーザー ID に
103 .I uid
104 を設定する。
105 これが行なわれた後にはプログラムが再びルートの特権を得ることはできない。
106 .PP
107 .\"O Thus, a set-user-ID-root program wishing to temporarily drop root
108 .\"O privileges, assume the identity of an unprivileged user, and then regain
109 .\"O root privileges afterward cannot use
110 .\"O .BR setuid ().
111 .\"O You can accomplish this with
112 .\"O .BR seteuid (2).
113 したがって、set-user-ID-root プログラムで、一時的にルート特権を解除し、
114 非特権ユーザであるかのように振舞い、後でルート権限をもう一度得ようと
115 する場合には、
116 .BR setuid ()
117 を使うことができない。その場合には、
118 .BR seteuid (2)
119 を使う必要がある。
120 .\"O .SH "RETURN VALUE"
121 .SH 返り値
122 .\"O On success, zero is returned.
123 .\"O On error, \-1 is returned, and
124 .\"O .I errno
125 .\"O is set appropriately.
126 成功した場合は 0 が返される。エラーの場合は \-1 が返され、
127 .I errno
128 が適切に設定される。
129 .\"O .SH ERRORS
130 .SH エラー
131 .TP
132 .B EAGAIN
133 .\"O The
134 .\"O .I uid
135 .\"O does not match the current uid and
136 .\"O .I uid
137 .\"O brings process over its
138 .\"O .B RLIMIT_NPROC
139 .\"O resource limit.
140 .I uid
141 が現在のユーザー ID とマッチせず、この
142 .I uid
143 によってプロセスがリソース上限
144 .B RLIMIT_NPROC
145 を超えた。
146 .TP
147 .B EPERM
148 .\"O The user is not privileged (Linux: does not have the
149 .\"O .B CAP_SETUID
150 .\"O capability) and
151 .\"O .I uid
152 .\"O does not match the real UID or saved set-user-ID of the calling process.
153 ユーザーが特権を持たず
154 (Linux では
155 .B CAP_SETUID
156 ケーパビリティ (capability) を持たず)、
157 .I uid
158 が呼び出し元プロセスの実 UID または保存 set-user-ID と一致しない。
159 .\"O .SH "CONFORMING TO"
160 .SH 準拠
161 .\"O SVr4, POSIX.1-2001.
162 .\"O Not quite compatible with the 4.4BSD call, which
163 .\"O sets all of the real, saved, and effective user IDs.
164 .\"O .\" SVr4 documents an additional EINVAL error condition.
165 SVr4, POSIX.1-2001.
166 4.4BSD のコールとは完全な互換性はない、
167 BSD のコールは実 (real)、保存 (saved)、実効 (effective) ID の全てを設定する。
168 .\" SVr4 には他に EINVAL エラーについての記述がある。
169 .\"O .SH NOTES
170 .\"O .SS Linux Notes
171 .SH 注意
172 .SS Linux での注意
173 .\"O Linux has the concept of file system user ID, normally equal to the
174 .\"O effective user ID.
175 .\"O The
176 .\"O .BR setuid ()
177 .\"O call also sets the file system user ID of the calling process.
178 .\"O See
179 .\"O .BR setfsuid (2).
180 Linux はファイル・システム・ユーザー ID の概念を持つ。
181 通常、これは実効ユーザー ID に等しい。
182 .BR setuid ()
183 コールは呼び出し元のプロセスのファイル・システム・ユーザー ID も設定する。
184 .BR setfsuid (2)
185 も参照すること。
186 .PP
187 .\"O If
188 .\"O .I uid
189 .\"O is different from the old effective uid, the process will
190 .\"O be forbidden from leaving core dumps.
191 .I uid
192 が昔の実効 uid と異っていた場合、プロセスはコア・ダンプすることを
193 禁止される。
194 .\"O .SH "SEE ALSO"
195 .SH 関連項目
196 .BR getuid (2),
197 .BR seteuid (2),
198 .BR setfsuid (2),
199 .BR setreuid (2),
200 .BR capabilities (7),
201 .BR credentials (7)