OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / draft / man2 / getgroups.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .\" Modified Thu Oct 31 12:04:29 1996 by Eric S. Raymond <esr@thyrsus.com>
26 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
27 .\"     Added notes on capability requirements
28 .\" 2008-05-03, mtk, expanded and rewrote parts of DESCRIPTION and RETURN
29 .\"     VALUE, made style of page more consistent with man-pages style.
30 .\"
31 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
32 .\"         all rights reserved.
33 .\" Translated 1997-02-22, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
34 .\" Updated 2001-02-10, Yuichi SATO <sato@complex.eng.hokudai.ac.jp>
35 .\" Updated & Modified 2004-12-30, Yuichi SATO <ysato444@yahoo.co.jp>
36 .\" Updated 2008-08-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
37 .\"
38 .\"WORD:        group                   ¥°¥ë¡¼¥×
39 .\"WORD:        access                  ¥¢¥¯¥»¥¹
40 .\"WORD:        process                 ¥×¥í¥»¥¹
41 .\"WORD:        super user              ¥¹¡¼¥Ñ¡¼¡¦¥æ¡¼¥¶¡¼
42 .\"WORD:        supplementary group     Êä½õ¥°¥ë¡¼¥×
43 .\"
44 .TH GETGROUPS 2 2008-06-03 "Linux" "Linux Programmer's Manual"
45 .\"O .SH NAME
46 .SH Ì¾Á°
47 .\"O getgroups, setgroups \- get/set list of supplementary group IDs
48 getgroups, setgroups \- Êä½õ¥°¥ë¡¼¥× ID ¤Î¥ê¥¹¥È¤ò¼èÆÀ/ÀßÄꤹ¤ë
49 .\"O .SH SYNOPSIS
50 .SH ½ñ¼°
51 .B #include <sys/types.h>
52 .br
53 .B #include <unistd.h>
54 .sp
55 .BI "int getgroups(int " size ", gid_t " list []);
56 .sp
57 .B #include <grp.h>
58 .sp
59 .BI "int setgroups(size_t " size ", const gid_t *" list );
60 .sp
61 .in -4n
62 .\"O Feature Test Macro Requirements for glibc (see
63 .\"O .BR feature_test_macros (7)):
64 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
65 .RB ( feature_test_macros (7)
66 »²¾È):
67 .in
68 .sp
69 .BR setgroups ():
70 _BSD_SOURCE
71 .\"O .SH DESCRIPTION
72 .SH ÀâÌÀ
73 .PP
74 .\"O .BR getgroups ()
75 .\"O returns the supplementary group IDs of the calling process in
76 .\"O .IR list .
77 .\"O The argument
78 .\"O .I size
79 .\"O should be set to the maximum number of items that can be stored in the
80 .\"O buffer pointed to by
81 .\"O .IR list .
82 .\"O If the calling process is a member of more than
83 .\"O .I size
84 .\"O supplementary groups, then an error results.
85 .BR getgroups ()
86 ¤Ï¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤ÎÊä½õ¥°¥ë¡¼¥× (supplementary group) ID ¤ò
87 .I list
88 ¤ËÊÖ¤¹¡£
89 .I size
90 °ú¤­¿ô¤Ë¤Ï¡¢
91 .I list
92 ¤Ë¤è¤ê»²¾È¤µ¤ì¤ë¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤Ç¤­¤ëÍ×ÁǤκÇÂç¿ô¤òÀßÄꤹ¤Ù¤­¤Ç¤¢¤ë¡£
93 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤¬
94 .I size
95 ¸Ä¤è¤ê¿¤¯¤ÎÊä½õ¥°¥ë¡¼¥×¤Î¥á¥ó¥Ð¤Î¾ì¹ç¤Ë¤Ï¡¢¥¨¥é¡¼¤È¤Ê¤ë¡£
96 .\"O It is unspecified whether the effective group ID of the calling process
97 .\"O is included in the returned list.
98 .\"O (Thus, an application should also call
99 .\"O .BR getegid (2)
100 .\"O and add or remove the resulting value.)
101 ¤³¤Î´Ø¿ô¤ò¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¼Â¸ú¥°¥ë¡¼¥× ID ¤¬¡¢
102 ÊÖ¤µ¤ì¤ë¥ê¥¹¥È¤Ë´Þ¤Þ¤ì¤ë¤«¤É¤¦¤«¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤
103 (¤·¤¿¤¬¤Ã¤Æ¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï
104 .BR getegid (2)
105 ¤ò¸Æ¤Ó½Ð¤·¡¢¤½¤Î·ë²Ì¤ÎÃͤòÄɲᦺï½ü¤¹¤Ù¤­¤Ç¤¢¤ë)¡£
106
107 .\"O If
108 .\"O .I size
109 .\"O is zero,
110 .\"O .I list
111 .\"O is not modified, but the total number of supplementary group IDs for the
112 .\"O process is returned.
113 .I size
114 ¤¬ 0 ¤Ê¤é¤Ð¡¢
115 .I list
116 ¤Ï½¤Àµ¤µ¤ì¤Ê¤¤¤¬¡¢¤½¤Î¥×¥í¥»¥¹¤ÎÊä½õ¥°¥ë¡¼¥× ID ¤Î¹ç·×¿ô¤¬ÊÖ¤µ¤ì¤ë¡£
117 .\"O This allows the caller to determine the size of a dynamically allocated
118 .\"O .I list
119 .\"O to be used in a further call to
120 .\"O .BR getgroups ().
121 ¤³¤ì¤ò»È¤¦¤³¤È¤Ç¡¢¤½¤ì°Ê¹ß¤Î
122 .BR getgroups ()
123 ¤Î¸Æ¤Ó½Ð¤·¤ÇɬÍפȤʤëưŪ³ä¤êÅö¤Æ¥Ð¥Ã¥Õ¥¡
124 .I list
125 ¤Î¥µ¥¤¥º¤ò¡¢¸Æ¤Ó½Ð¤·¸µ¤¬·èÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
126 .PP
127 .\"O .BR setgroups ()
128 .\"O sets the supplementary group IDs for the calling process.
129 .\"O Appropriate privileges (Linux: the
130 .\"O .B CAP_SETGID
131 .\"O capability) are required.
132 .BR setgroups ()
133 ¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤ÎÊä½õ¥°¥ë¡¼¥× ID ¤òÀßÄꤹ¤ë¡£
134 ŬÀÚ¤ÊÆø¢ (Linux ¤Ç¤Ï
135 .B CAP_SETGID
136 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£ (capability)) ¤¬É¬ÍפǤ¢¤ë¡£
137 .\"O The
138 .\"O .I size
139 .\"O argument specifies the number of supplementary group IDs
140 .\"O in the buffer pointed to by
141 .\"O .IR list .
142 .I size
143 °ú¤­¿ô¤Ë¤Ï¡¢
144 .I list
145 ¤Ë¤è¤ê»²¾È¤µ¤ì¤ë¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤¿Êä½õ¥°¥ë¡¼¥× ID ¤Î¿ô¤ò»ØÄꤹ¤ë¡£
146 .\"O .SH "RETURN VALUE"
147 .SH ÊÖ¤êÃÍ
148 .\"O On success,
149 .\"O .BR getgroups ()
150 .\"O returns the number of supplementary group IDs.
151 .\"O On error, \-1 is returned, and
152 .\"O .I errno
153 .\"O is set appropriately.
154 .BR getgroups ()
155 ¤Ï¡¢À®¸ù¤¹¤ë¤ÈÊä½õ¥°¥ë¡¼¥× ID ¤Î¿ô¤òÊÖ¤¹¡£
156 ¥¨¥é¡¼¤Î¾ì¹ç \-1 ¤òÊÖ¤·¡¢
157 .I errno
158 ¤òŬÀÚ¤ËÀßÄꤹ¤ë¡£
159
160 .\"O On success,
161 .\"O .BR setgroups ()
162 .\"O returns 0.
163 .\"O On error, \-1 is returned, and
164 .\"O .I errno
165 .\"O is set appropriately.
166 .BR setgroups ()
167 ¤Ï¡¢À®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤¹¡£
168 ¥¨¥é¡¼¤Î¾ì¹ç \-1 ¤òÊÖ¤·¡¢
169 .I errno
170 ¤òŬÀÚ¤ËÀßÄꤹ¤ë¡£
171 .\"O .SH ERRORS
172 .SH ¥¨¥é¡¼
173 .TP
174 .B EFAULT
175 .\"O .I list
176 .\"O has an invalid address.
177 .I list
178 ¤¬ÉÔÀµ¤Ê¥¢¥É¥ì¥¹¤Ç¤¢¤ë¡£
179 .PP
180 .\"O .BR getgroups ()
181 .\"O can additionally fail with the following error:
182 .BR getgroups ()
183 ¤Ï¡¢¾åµ­¤Ë²Ã¤¨¤Æ°Ê²¼¤Î¥¨¥é¡¼¤Ç¼ºÇÔ¤¹¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
184 .TP
185 .B EINVAL
186 .\"O .I size
187 .\"O is less than the number of supplementary group IDs, but is not zero.
188 .I size
189 ¤¬Êä½õ¥°¥ë¡¼¥× ID ¤Î¿ô¤è¤ê¾®¤µ¤¤¤¬ 0 ¤Ç¤Ê¤¤¡£
190 .PP
191 .\"O .BR setgroups ()
192 .\"O can additionally fail with the following errors:
193 .BR setgroups ()
194 ¤Ï¡¢¾åµ­¤Ë²Ã¤¨¤Æ°Ê²¼¤Î¥¨¥é¡¼¤Ç¼ºÇÔ¤¹¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
195 .TP
196 .B EINVAL
197 .\"O .I size
198 .\"O is greater than
199 .\"O .B NGROUPS_MAX
200 .\"O (32 before Linux 2.6.4; 65536 since Linux 2.6.4).
201 .I size
202 ¤¬
203 .B NGROUPS_MAX
204 ¤è¤êÂ礭¤¤
205 .RB ( NGROUPS_MAX
206 ¤Ï Linux 2.6.4 ¤è¤êÁ°¤Ç¤Ï 32¡¢Linux 2.6.4 °Ê¹ß¤Ç¤Ï 65536)¡£
207 .TP
208 .B ENOMEM
209 .\"O Out of memory.
210 ¥á¥â¥êÉÔ­¡£
211 .TP
212 .B EPERM
213 .\"O The calling process has insufficient privilege.
214 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤¬½½Ê¬¤ÊÆø¢¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£
215 .\"O .SH "CONFORMING TO"
216 .SH ½àµò
217 .\"O SVr4, 4.3BSD.
218 .\"O The
219 .\"O .BR getgroups ()
220 .\"O function is in POSIX.1-2001.
221 .\"O Since
222 .\"O .BR setgroups ()
223 .\"O requires privilege, it is not covered by POSIX.1-2001.
224 SVr4, 4.3BSD.
225 .BR getgroups ()
226 ´Ø¿ô¤Ï POSIX.1-2001 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
227 .BR setgroups ()
228 ¤ÏÆø¢¤òɬÍפȤ¹¤ë¤¿¤á¡¢POSIX.1-2001 ¤Ë½¾¤Ã¤Æ¤¤¤Ê¤¤¡£
229 .\"O .SH NOTES
230 .SH Ãí°Õ
231 .\"O A process can have up to
232 .\"O .B NGROUPS_MAX
233 .\"O supplementary group IDs
234 .\"O in addition to the effective group ID.
235 .\"O The set of supplementary group IDs
236 .\"O is inherited from the parent process, and preserved across an
237 .\"O .BR execve (2).
238 ¥×¥í¥»¥¹¤Ï¡¢¼Â¸ú¥°¥ë¡¼¥× ID ¤Ë²Ã¤¨¡¢ºÇÂç
239 .B NGROUPS_MAX
240 ¤Þ¤Ç¤ÎÊä½õ¥°¥ë¡¼¥× ID ¤ò»ý¤Ä¤³¤È¤¬¤Ç¤­¤ë¡£
241 Êä½õ¥°¥ë¡¼¥× ID ¤Î½¸¹ç¤Ï¿Æ¥×¥í¥»¥¹¤«¤é·Ñ¾µ¤µ¤ì¡¢
242 .BR execve (2)
243 ¤ÎÁ°¸å¤ÇÊÝ»ý¤µ¤ì¤ë¡£
244
245 .\"O The maximum number of supplementary group IDs can be found using
246 .\"O .BR sysconf (3):
247 Êä½õ¥°¥ë¡¼¥× ID ¤ÎºÇÂç¿ô¤Ï
248 .BR sysconf (3)
249 ¤ò»È¤Ã¤Æ°Ê²¼¤Î¤è¤¦¤Ë¤·¤ÆÄ´¤Ù¤ë¤³¤È¤¬¤Ç¤­¤ë:
250 .nf
251
252     long ngroups_max;
253     ngroups_max = sysconf(_SC_NGROUPS_MAX);
254
255 .fi
256 .\"O The maximum return value of
257 .\"O .BR getgroups ()
258 .\"O cannot be larger than one more than this value.
259 .BR getgroups ()
260 ¤ÎÊÖ¤êÃͤκÇÂçÃͤϡ¢¤³¤ÎÃͤè¤ê 1 Â礭¤¤Ãͤè¤êÂ礭¤¯¤Ê¤ë¤³¤È¤Ï¤Ê¤¤¡£
261 .\"O .SH "SEE ALSO"
262 .SH ´ØÏ¢¹àÌÜ
263 .BR getgid (2),
264 .BR setgid (2),
265 .BR getgrouplist (3),
266 .BR initgroups (3),
267 .BR capabilities (7),
268 .BR credentials (7)