1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" References consulted:
25 .\" Linux libc source code
26 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
29 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
30 .\" Modified 2003-11-15 by aeb
32 .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka
33 .\" all rights reserved.
34 .\" Translated 1997-12-19, HIROFUMI Nishizuka <nishi@rpts.cl.nec.co.jp>
35 .\" Updated & Modefied 1999-02-26, Shouichi Saito
36 .\" Updated & Modified 2004-06-05, Yuichi SATO <ysato444@yahoo.co.jp>
37 .\" Updated & Modified 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
38 .\" Updated 2008-12-24, Akihiro MOTOKI, LDP v3.14
40 .TH GETGRNAM 3 2009-03-30 "" "Linux Programmer's Manual"
43 .\"O getgrnam, getgrnam_r, getgrgid, getgrgid_r \- get group file entry
44 getgrnam, getgrnam_r, getgrgid, getgrgid_r \- ¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë¥¨¥ó¥È¥ê¤Î¼è¤ê½Ð¤·
48 .B #include <sys/types.h>
51 .BI "struct group *getgrnam(const char *" name );
53 .BI "struct group *getgrgid(gid_t " gid );
55 .BI "int getgrnam_r(const char *" name ", struct group *" grp ,
57 .BI " char *" buf ", size_t " buflen ", struct group **" result );
59 .BI "int getgrgid_r(gid_t " gid ", struct group *" grp ,
61 .BI " char *" buf ", size_t " buflen ", struct group **" result );
65 .\"O Feature Test Macro Requirements for glibc (see
66 .\"O .BR feature_test_macros (7)):
67 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
68 .RB ( feature_test_macros (7)
76 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE ||
77 _SVID_SOURCE || _POSIX_SOURCE
84 .\"O function returns a pointer to a structure containing
85 .\"O the broken-out fields of the record in the group database
86 .\"O (e.g., the local group file
89 .\"O that matches the group name
94 ¤Ë¥Þ¥Ã¥Á¤¹¤ë¥°¥ë¡¼¥×¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥¨¥ó¥È¥ê¤ò
95 Í×ÁÇËè¤Ëʬ²ò¤·¡¢³ÆÍ×ÁǤò³ÊǼ¤·¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹
96 (¥Ñ¥¹¥ï¡¼¥É¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÎã:
97 ¥í¡¼¥«¥ë¤Î¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë
103 .\"O function returns a pointer to a structure containing
104 .\"O the broken-out fields of the record in the group database
105 .\"O that matches the group ID
110 ¤Ë¥Þ¥Ã¥Á¤¹¤ë¥°¥ë¡¼¥×¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥¨¥ó¥È¥ê¤ò
111 Í×ÁÇËè¤Ëʬ²ò¤·¡¢³ÆÍ×ÁǤò³ÊǼ¤·¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
114 .\"O .BR getgrnam_r ()
116 .\"O .BR getgrgid_r ()
117 .\"O functions obtain the same information, but store the retrieved
120 .\"O in the space pointed to by
125 ´Ø¿ô¤Ï (¾åµ¤Î´Ø¿ô¤È) Ʊ¤¸¾ðÊó¤ò¼èÆÀ¤¹¤ë¤¬¡¢
130 ¤¬»Ø¤¹Îΰè¤Ë³ÊǼ¤¹¤ë¡£
133 .\"O structure contains pointers to strings, and these strings
134 .\"O are stored in the buffer
140 ¹½Â¤ÂΤˤÏʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬´Þ¤Þ¤ì¡¢
141 ¤³¤ì¤é¤Îʸ»úÎó¤Ï¥µ¥¤¥º
146 .\"O A pointer to the result (in case of success) or NULL (in case no entry
147 .\"O was found or an error occurred) is stored in
151 ¤Ë¤Ï·ë²Ì¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬³ÊǼ¤µ¤ì¤ë¡£
152 ¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤ä¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ë¤Ï
156 .\"O The \fIgroup\fP structure is defined in \fI<grp.h>\fP as follows:
157 \fIgroup\fP ¹½Â¤ÂΤϡ¢\fI<grp.h>\fP ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
162 .\"O char *gr_name; /* group name */
163 .\"O char *gr_passwd; /* group password */
164 .\"O gid_t gr_gid; /* group ID */
165 .\"O char **gr_mem; /* group members */
166 char *gr_name; /* ¥°¥ë¡¼¥×̾ */
167 char *gr_passwd; /* ¥°¥ë¡¼¥×¤Î¥Ð¥¹¥ï¡¼¥É */
168 gid_t gr_gid; /* ¥°¥ë¡¼¥× ID */
169 char **gr_mem; /* ¥°¥ë¡¼¥×¤Î¥á¥ó¥Ð */
174 .\"O The maximum needed size for
176 .\"O can be found using
178 .\"O with the argument
179 .\"O .BR _SC_GETGR_R_SIZE_MAX .
181 ¤ËºÇÂçɬÍפʥµ¥¤¥º¤Ï¡¢
184 .B _SC_GETGR_R_SIZE_MAX
185 ¤ò»ØÄꤷ¤Æ¼Â¹Ô¤¹¤ë¤³¤È¤Çʬ¤«¤ë¡£
186 .\"O .SH "RETURN VALUE"
192 .\"O functions return a pointer to a
194 .\"O structure, or NULL if the matching entry
195 .\"O is not found or an error occurs.
201 ¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
202 ¥Þ¥Ã¥Á¤¹¤ë¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤ä¡¢
203 ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï NULL ¤òÊÖ¤¹¡£
204 .\"O If an error occurs,
206 .\"O is set appropriately.
207 .\"O If one wants to check
209 .\"O after the call, it should be set to zero before the call.
210 ¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¾ì¹ç¡¢
215 ¤ò¥Á¥§¥Ã¥¯¤·¤¿¤¤¾ì¹ç¤Ï¡¢
216 ¸Æ¤Ó½Ð¤·¤ÎÁ°¤Ë (¤³¤ÎÃͤò) 0 ¤ËÀßÄꤷ¤Æ¤ª¤¯¤Ù¤¤Ç¤¢¤ë¡£
218 .\"O The return value may point to a static area, and may be overwritten
219 .\"O by subsequent calls to
220 .\"O .BR getgrent (3),
221 .\"O .BR getgrgid (),
223 .\"O .BR getgrnam ().
224 .\"O (Do not pass the returned pointer to
226 ÊÖ¤êÃͤÏÀÅŪ¤ÊÎΰè¤ò»Ø¤·¤Æ¤ª¤ê¡¢¤½¤Î¸å¤Î
230 ¤Î¸Æ¤Ó½Ð¤·¤Ç¾å½ñ¤¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
236 .\"O .BR getgrnam_r ()
238 .\"O .BR getgrgid_r ()
239 .\"O return zero, and set
243 .\"O If no matching group record was found,
244 .\"O these functions return 0 and store NULL in
246 .\"O In case of error, an error number is returned, and NULL is stored in
257 ¥Þ¥Ã¥Á¤¹¤ë¥°¥ë¡¼¥×¡¦¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢
261 ¥¨¥é¡¼¤Î¾ì¹ç¡¢¥¨¥é¡¼ÈÖ¹æ¤òÊÖ¤·¡¢
267 .\"O .BR 0 " or " ENOENT " or " ESRCH " or " EBADF " or " EPERM " or ... "
268 .BR 0 " ¤Þ¤¿¤Ï " ENOENT " ¤Þ¤¿¤Ï " ESRCH " ¤Þ¤¿¤Ï " EBADF " ¤Þ¤¿¤Ï " EPERM " ¤Þ¤¿¤Ï ... "
281 .\"O A signal was caught.
282 ¥·¥°¥Ê¥ë¤¬¥¥ã¥Ã¥Á¤µ¤ì¤¿¡£
289 .\"O The maximum number
290 .\"O .RB ( OPEN_MAX )
291 .\"O of files was open already in the calling process.
292 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Ë¤ª¤¤¤Æ¡¢
295 ¤Î¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¡£
298 .\"O The maximum number of files was open already in the system.
299 ¥·¥¹¥Æ¥à¾å¤Ç´û¤ËºÇÂç¿ô¤Î¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¡£
302 .\"O .\" not in POSIX
303 .\"O Insufficient memory to allocate
306 .\"O .\" to allocate the group structure, or to allocate buffers
309 ¹½Â¤ÂΤò³ä¤êÅö¤Æ¤ë¤¿¤á¤Î¥á¥â¥ê¤¬ÉÔ½½Ê¬¡£
310 .\" ¥°¥ë¡¼¥×¾ðÊó¹½Â¤ÂΤò³ä¤êÅö¤Æ¤ë¤¿¤á¡¢¤Þ¤¿¤Ï¥Ð¥Ã¥Õ¥¡¤ò³ä¤êÅö¤Æ¤ë¤¿¤á¤Î
313 .\"O Insufficient buffer space supplied.
314 Í¿¤¨¤é¤ì¤¿¥Ð¥Ã¥Õ¥¡¶õ´Ö¤¬ÉÔ½½Ê¬¤Ç¤¢¤ë¡£
319 .\"O local group database file
320 ¥í¡¼¥«¥ë¤Î¥°¥ë¡¼¥×¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë
321 .\"O .SH "CONFORMING TO"
323 SVr4, 4.3BSD, POSIX.1-2001.
326 .\"O The formulation given above under "RETURN VALUE" is from POSIX.1-2001.
327 ¾åµ¤Î¡ÖÊÖ¤êÃ͡װʲ¼¤Îµ½Ò¤Ï POSIX.1-2001 ¤Ëµò¤ë¡£
328 .\"O It does not call "not found" an error, hence does not specify what value
330 .\"O might have in this situation.
331 .\"O But that makes it impossible to recognize
333 .\"O One might argue that according to POSIX
335 .\"O should be left unchanged if an entry is not found.
336 .\"O Experiments on various
337 .\"O UNIX-like systems shows that lots of different values occur in this
338 .\"O situation: 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM and probably others.
339 ¤³¤Îɸ½à¤Ï¡Ö(¥¨¥ó¥È¥ê¤¬) ¸«¤Ä¤«¤é¤Ê¤¤¤³¤È¡×¤ò¥¨¥é¡¼¤È¤·¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢
342 ¤¬¤É¤Î¤è¤¦¤ÊÃͤˤʤ뤫¤òÄê¤á¤Æ¤¤¤Ê¤¤¡£
343 ¤½¤Î¤¿¤á¡¢¥¨¥é¡¼¤òǧ¼±¤¹¤ë¤³¤È¤ÏÉÔ²Äǽ¤Ç¤¢¤ë¡£
344 POSIX ¤Ë½àµò¤·¤Æ¡¢¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤¤¾ì¹ç¤Ï
346 ¤òÊѹ¹¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤Ù¤¤Ç¤¢¤ë¡¢¤È¼çÄ¥¤¹¤ë¿Í¤â¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
347 ÍÍ¡¹¤Ê UNIX ·Ï¤Î¥·¥¹¥Æ¥à¤Ç»î¤·¤Æ¤ß¤ë¤È¡¢¤½¤Î¤è¤¦¤Ê¾ì¹ç¤Ë¤Ï
348 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM ¤È¤¤¤Ã¤¿ÍÍ¡¹¤ÊÃͤ¬ÊÖ¤µ¤ì¤ë¡£
349 ¾¤ÎÃͤ¬ÊÖ¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
350 .\"O .\" more precisely:
351 .\"O .\" AIX 5.1 - gives ESRCH
352 .\"O .\" OSF1 4.0g - gives EWOULDBLOCK
353 .\"O .\" libc, glibc up to version 2.6, Irix 6.5 - give ENOENT
354 .\"O .\" glibc since version 2.7 - give 0
355 .\"O .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 - give EPERM
356 .\"O .\" SunOS 5.8 - gives EBADF
357 .\"O .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 - give 0
359 .\" AIX 5.1 ¤Ï ESRCH ¤òÊÖ¤¹¡£
360 .\" OSF1 4.0g ¤Ï EWOULDBLOCK ¤òÊÖ¤¹¡£
361 .\" libc, glibc (¥Ð¡¼¥¸¥ç¥ó 2.6 ¤Þ¤Ç), Irix 6.5 ¤Ï ENOENT ¤òÊÖ¤¹¡£
362 .\" glibc (¥Ð¡¼¥¸¥ç¥ó 2.7 °Ê¹ß) ¤Ï 0 ¤òÊÖ¤¹¡£
363 .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 ¤Ï EPERM ¤òÊÖ¤¹¡£
364 .\" SunOS 5.8 ¤Ï EBADF ¤òÊÖ¤¹¡£
365 .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 ¤Ï 0 ¤òÊÖ¤¹¡£