OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[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 afterwards 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)