OSDN Git Service

0871e9dd63d0963d55208cdf48837adbdd319bc7
[linuxjm/LDP_man-pages.git] / release / 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 .SH 名前
50 setuid \- ユーザー識別 (identity) を設定する
51 .SH 書式
52 .B #include <sys/types.h>
53 .br
54 .B #include <unistd.h>
55 .sp
56 .BI "int setuid(uid_t " uid );
57 .SH 説明
58 .BR setuid ()
59 は呼び出し元のプロセスの実効 (effective) ユーザー ID を設定する。
60 もし呼び出し元プロセスの実効 UID が root ならば、
61 実 (real) UID と保存 (saved) set-user-ID も設定される。
62 .PP
63 Linux では、
64 .BR setuid ()
65
66 .B _POSIX_SAVED_IDS
67 をもった POSIX 版のように実装されている。
68 これは (ルート以外の) set-user-ID プログラムにそのユーザーの特権を
69 全て与え、特権の必要ない仕事をし、本来の実効ユーザー ID に
70 安全な方法で再び戻すことを許す。
71 .PP
72 ユーザーが root またはプログラムが root に set-user-ID されているならば、
73 特別の注意が払われる。
74 .BR setuid ()
75 関数は呼び出し者の実効ユーザー ID をチェックし、
76 それがスーパー・ユーザーならば、
77 プロセスに関連する全てのユーザー ID に
78 .I uid
79 を設定する。
80 これが行なわれた後にはプログラムが再びルートの特権を得ることはできない。
81 .PP
82 したがって、set-user-ID-root プログラムで、一時的にルート特権を解除し、
83 非特権ユーザであるかのように振舞い、後でルート権限をもう一度得ようと
84 する場合には、
85 .BR setuid ()
86 を使うことができない。その場合には、
87 .BR seteuid (2)
88 を使う必要がある。
89 .SH 返り値
90 成功した場合は 0 が返される。エラーの場合は \-1 が返され、
91 .I errno
92 が適切に設定される。
93 .SH エラー
94 .TP
95 .B EAGAIN
96 .I uid
97 が現在のユーザー ID とマッチせず、この
98 .I uid
99 によってプロセスがリソース上限
100 .B RLIMIT_NPROC
101 を超えた。
102 .TP
103 .B EPERM
104 ユーザーが特権を持たず
105 (Linux では
106 .B CAP_SETUID
107 ケーパビリティ (capability) を持たず)、
108 .I uid
109 が呼び出し元プロセスの実 UID または保存 set-user-ID と一致しない。
110 .SH 準拠
111 SVr4, POSIX.1-2001.
112 4.4BSD のコールとは完全な互換性はない、
113 BSD のコールは実 (real)、保存 (saved)、実効 (effective) ID の全てを設定する。
114 .\" SVr4 には他に EINVAL エラーについての記述がある。
115 .SH 注意
116 .SS Linux での注意
117 Linux はファイル・システム・ユーザー ID の概念を持つ。
118 通常、これは実効ユーザー ID に等しい。
119 .BR setuid ()
120 コールは呼び出し元のプロセスのファイル・システム・ユーザー ID も設定する。
121 .BR setfsuid (2)
122 も参照すること。
123 .PP
124 .I uid
125 が昔の実効 uid と異っていた場合、プロセスはコア・ダンプすることを
126 禁止される。
127 .SH 関連項目
128 .BR getuid (2),
129 .BR seteuid (2),
130 .BR setfsuid (2),
131 .BR setreuid (2),
132 .BR capabilities (7),
133 .BR credentials (7)