1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
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.
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
38 .\"WORD: group ¥°¥ë¡¼¥×
39 .\"WORD: access ¥¢¥¯¥»¥¹
40 .\"WORD: process ¥×¥í¥»¥¹
41 .\"WORD: super user ¥¹¡¼¥Ñ¡¼¡¦¥æ¡¼¥¶¡¼
42 .\"WORD: supplementary group Êä½õ¥°¥ë¡¼¥×
44 .TH GETGROUPS 2 2008-06-03 "Linux" "Linux Programmer's Manual"
47 .\"O getgroups, setgroups \- get/set list of supplementary group IDs
48 getgroups, setgroups \- Êä½õ¥°¥ë¡¼¥× ID ¤Î¥ê¥¹¥È¤ò¼èÆÀ/ÀßÄꤹ¤ë
51 .B #include <sys/types.h>
53 .B #include <unistd.h>
55 .BI "int getgroups(int " size ", gid_t " list []);
59 .BI "int setgroups(size_t " size ", const gid_t *" list );
62 .\"O Feature Test Macro Requirements for glibc (see
63 .\"O .BR feature_test_macros (7)):
64 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
65 .RB ( feature_test_macros (7)
75 .\"O returns the supplementary group IDs of the calling process in
79 .\"O should be set to the maximum number of items that can be stored in the
80 .\"O buffer pointed to by
82 .\"O If the calling process is a member of more than
84 .\"O supplementary groups, then an error results.
86 ¤Ï¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤ÎÊä½õ¥°¥ë¡¼¥× (supplementary group) ID ¤ò
92 ¤Ë¤è¤ê»²¾È¤µ¤ì¤ë¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤Ç¤¤ëÍ×ÁǤκÇÂç¿ô¤òÀßÄꤹ¤Ù¤¤Ç¤¢¤ë¡£
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
100 .\"O and add or remove the resulting value.)
101 ¤³¤Î´Ø¿ô¤ò¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¼Â¸ú¥°¥ë¡¼¥× ID ¤¬¡¢
102 ÊÖ¤µ¤ì¤ë¥ê¥¹¥È¤Ë´Þ¤Þ¤ì¤ë¤«¤É¤¦¤«¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤
103 (¤·¤¿¤¬¤Ã¤Æ¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï
105 ¤ò¸Æ¤Ó½Ð¤·¡¢¤½¤Î·ë²Ì¤ÎÃͤòÄɲᦺï½ü¤¹¤Ù¤¤Ç¤¢¤ë)¡£
111 .\"O is not modified, but the total number of supplementary group IDs for the
112 .\"O process is returned.
116 ¤Ï½¤Àµ¤µ¤ì¤Ê¤¤¤¬¡¢¤½¤Î¥×¥í¥»¥¹¤ÎÊä½õ¥°¥ë¡¼¥× ID ¤Î¹ç·×¿ô¤¬ÊÖ¤µ¤ì¤ë¡£
117 .\"O This allows the caller to determine the size of a dynamically allocated
119 .\"O to be used in a further call to
120 .\"O .BR getgroups ().
121 ¤³¤ì¤ò»È¤¦¤³¤È¤Ç¡¢¤½¤ì°Ê¹ß¤Î
123 ¤Î¸Æ¤Ó½Ð¤·¤ÇɬÍפȤʤëưŪ³ä¤êÅö¤Æ¥Ð¥Ã¥Õ¥¡
125 ¤Î¥µ¥¤¥º¤ò¡¢¸Æ¤Ó½Ð¤·¸µ¤¬·èÄꤹ¤ë¤³¤È¤¬¤Ç¤¤ë¡£
127 .\"O .BR setgroups ()
128 .\"O sets the supplementary group IDs for the calling process.
129 .\"O Appropriate privileges (Linux: the
131 .\"O capability) are required.
133 ¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤ÎÊä½õ¥°¥ë¡¼¥× ID ¤òÀßÄꤹ¤ë¡£
134 ŬÀÚ¤ÊÆø¢ (Linux ¤Ç¤Ï
136 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£ (capability)) ¤¬É¬ÍפǤ¢¤ë¡£
139 .\"O argument specifies the number of supplementary group IDs
140 .\"O in the buffer pointed to by
145 ¤Ë¤è¤ê»²¾È¤µ¤ì¤ë¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤¿Êä½õ¥°¥ë¡¼¥× ID ¤Î¿ô¤ò»ØÄꤹ¤ë¡£
146 .\"O .SH "RETURN VALUE"
149 .\"O .BR getgroups ()
150 .\"O returns the number of supplementary group IDs.
151 .\"O On error, \-1 is returned, and
153 .\"O is set appropriately.
155 ¤Ï¡¢À®¸ù¤¹¤ë¤ÈÊä½õ¥°¥ë¡¼¥× ID ¤Î¿ô¤òÊÖ¤¹¡£
156 ¥¨¥é¡¼¤Î¾ì¹ç \-1 ¤òÊÖ¤·¡¢
161 .\"O .BR setgroups ()
163 .\"O On error, \-1 is returned, and
165 .\"O is set appropriately.
167 ¤Ï¡¢À®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤¹¡£
168 ¥¨¥é¡¼¤Î¾ì¹ç \-1 ¤òÊÖ¤·¡¢
176 .\"O has an invalid address.
178 ¤¬ÉÔÀµ¤Ê¥¢¥É¥ì¥¹¤Ç¤¢¤ë¡£
180 .\"O .BR getgroups ()
181 .\"O can additionally fail with the following error:
183 ¤Ï¡¢¾åµ¤Ë²Ã¤¨¤Æ°Ê²¼¤Î¥¨¥é¡¼¤Ç¼ºÇÔ¤¹¤ë²ÄǽÀ¤¬¤¢¤ë¡£
187 .\"O is less than the number of supplementary group IDs, but is not zero.
189 ¤¬Êä½õ¥°¥ë¡¼¥× ID ¤Î¿ô¤è¤ê¾®¤µ¤¤¤¬ 0 ¤Ç¤Ê¤¤¡£
191 .\"O .BR setgroups ()
192 .\"O can additionally fail with the following errors:
194 ¤Ï¡¢¾åµ¤Ë²Ã¤¨¤Æ°Ê²¼¤Î¥¨¥é¡¼¤Ç¼ºÇÔ¤¹¤ë²ÄǽÀ¤¬¤¢¤ë¡£
200 .\"O (32 before Linux 2.6.4; 65536 since Linux 2.6.4).
206 ¤Ï Linux 2.6.4 ¤è¤êÁ°¤Ç¤Ï 32¡¢Linux 2.6.4 °Ê¹ß¤Ç¤Ï 65536)¡£
213 .\"O The calling process has insufficient privilege.
214 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤¬½½Ê¬¤ÊÆø¢¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£
215 .\"O .SH "CONFORMING TO"
219 .\"O .BR getgroups ()
220 .\"O function is in POSIX.1-2001.
222 .\"O .BR setgroups ()
223 .\"O requires privilege, it is not covered by POSIX.1-2001.
226 ´Ø¿ô¤Ï POSIX.1-2001 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
228 ¤ÏÆø¢¤òɬÍפȤ¹¤ë¤¿¤á¡¢POSIX.1-2001 ¤Ë½¾¤Ã¤Æ¤¤¤Ê¤¤¡£
231 .\"O A process can have up to
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
238 ¥×¥í¥»¥¹¤Ï¡¢¼Â¸ú¥°¥ë¡¼¥× ID ¤Ë²Ã¤¨¡¢ºÇÂç
240 ¤Þ¤Ç¤ÎÊä½õ¥°¥ë¡¼¥× ID ¤ò»ý¤Ä¤³¤È¤¬¤Ç¤¤ë¡£
241 Êä½õ¥°¥ë¡¼¥× ID ¤Î½¸¹ç¤Ï¿Æ¥×¥í¥»¥¹¤«¤é·Ñ¾µ¤µ¤ì¡¢
245 .\"O The maximum number of supplementary group IDs can be found using
246 .\"O .BR sysconf (3):
247 Êä½õ¥°¥ë¡¼¥× ID ¤ÎºÇÂç¿ô¤Ï
249 ¤ò»È¤Ã¤Æ°Ê²¼¤Î¤è¤¦¤Ë¤·¤ÆÄ´¤Ù¤ë¤³¤È¤¬¤Ç¤¤ë:
253 ngroups_max = sysconf(_SC_NGROUPS_MAX);
256 .\"O The maximum return value of
257 .\"O .BR getgroups ()
258 .\"O cannot be larger than one more than this value.
260 ¤ÎÊÖ¤êÃͤκÇÂçÃͤϡ¢¤³¤ÎÃͤè¤ê 1 Â礤¤Ãͤè¤êÂ礤¯¤Ê¤ë¤³¤È¤Ï¤Ê¤¤¡£
265 .BR getgrouplist (3),
267 .BR capabilities (7),