OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[linuxjm/LDP_man-pages.git] / release / man2 / seteuid.2
1 .\" Copyright (C) 2001 Andries Brouwer (aeb@cwi.nl)
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 .\" [should really be seteuid.3]
24 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
25 .\"     Added notes on capability requirements
26 .\"
27 .\" Japanese Version Copyright (c) 2001, 2005 Yuichi SATO
28 .\"         all rights reserved.
29 .\" Translated 2001-06-04, Yuichi SATO <ysato@h4.dion.ne.jp>
30 .\" Updated & Modified 2005-01-04, Yuichi SATO <ysato444@yahoo.co.jp>
31 .\" Updated 2010-04-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.24
32 .\"
33 .\"WORD:        effective user ID       実効ユーザー ID
34 .\"WORD:        real user ID            実ユーザー ID
35 .\"WORD:        saved user ID           保存ユーザー ID
36 .\"WORD:
37 .\"
38 .TH SETEUID 2 2009-10-17 "Linux" "Linux Programmer's Manual"
39 .SH 名前
40 seteuid, setegid \- 実効ユーザー ID や 実効グループ ID を設定する
41 .SH 書式
42 .B #include <sys/types.h>
43 .br
44 .B #include <unistd.h>
45 .sp
46 .BI "int seteuid(uid_t " euid );
47 .br
48 .BI "int setegid(gid_t " egid );
49 .sp
50 .in -4n
51 glibc 向けの機能検査マクロの要件
52 .RB ( feature_test_macros (7)
53 参照):
54 .in
55 .sp
56 .ad l
57 .BR seteuid (),
58 .BR setegid ():
59 .RS 4
60 _BSD_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
61 .RE
62 .ad
63 .SH 説明
64 .BR seteuid ()
65 は呼び出し元のプロセスの実効ユーザー ID を設定する。
66 非特権ユーザーのプロセスの場合、実効ユーザー ID に設定できるのは、
67 実ユーザー ID・実効ユーザー ID・保存 set-user-ID のいずれかだけである。
68
69 .BR setegid ()
70 は「ユーザー」ではなく「グループ」に対して全く同じことを行う。
71 .\" When
72 .\" .I euid
73 .\" equals \-1, nothing is changed.
74 .\" (This is an artifact of the implementation in glibc of seteuid()
75 .\" using setresuid(2).)
76 .SH 返り値
77 成功した場合は 0 が返される。
78 エラーの場合は \-1 が返され、
79 .I errno
80 が適切に設定される。
81
82 .SH エラー
83 .\" .TP
84 .\" .B EINVAL
85 .TP
86 .B EPERM
87 呼び出し元のプロセスに特権がなく、
88 .I euid
89 .RI ( egid )
90 が実ユーザー (グループ) ID、または実効ユーザー (グループ) ID、
91 保存 set-user-ID (保存 set-group-ID) のいずれでもではない
92 (Linux においては、
93 .BR seteuid ()
94 では
95 .B CAP_SETUID
96 ケーパビリティ (capability) が、
97 .BR setegid ()
98 では
99 .B CAP_SETGID
100 ケーパビリティがない場合に、特権がないと判断される)。
101 .SH 準拠
102 4.3BSD, POSIX.1-2001.
103 .SH 注意
104 実効ユーザー (グループ) ID を保存 set-user-ID (保存 set-group-ID) に
105 設定できるのは、Linux 1.1.37 (1.1.38) 以降である。
106 全てのシステムにおいて
107 .B _POSIX_SAVED_IDS
108 をチェックすべきである。
109 .LP
110 libc4, libc5, glibc 2.0 では、
111 .BI seteuid( euid )
112
113 .BI setreuid(\-1, " euid" )
114 と等価であり、保存 set-user-ID を変更するかもしれない。
115 glibc 2.1 では、
116 .BI setresuid(\-1, " euid" ", \-1)"
117 と等価であり、保存 set-user-ID 変更しない。
118 同様のことが
119 .BR setegid ()
120 にも言える。
121
122 POSIX.1 では、
123 .BR seteuid ()
124 .RB ( setegid ())
125 で、
126 .I euid
127 .RI ( egid )
128 として現在の実効ユーザ (グループ) ID と同じ値を指定可能である
129 必要はないとされており、いくつかの実装では
130 .I euid
131 .RI ( egid )
132 として現在の実効ユーザ (グループ) ID と同じ値を
133 指定することができない。
134 .SH 関連項目
135 .BR geteuid (2),
136 .BR setresuid (2),
137 .BR setreuid (2),
138 .BR setuid (2),
139 .BR capabilities (7),
140 .BR credentials (7)