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)
75 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE ||
76 _SVID_SOURCE || _POSIX_SOURCE
82 .\"O function returns a pointer to a structure containing
83 .\"O the broken-out fields of the record in the group database
84 .\"O (e.g., the local group file
87 .\"O that matches the group name
92 ¤Ë¥Þ¥Ã¥Á¤¹¤ë¥°¥ë¡¼¥×¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥¨¥ó¥È¥ê¤ò
93 Í×ÁÇËè¤Ëʬ²ò¤·¡¢³ÆÍ×ÁǤò³ÊǼ¤·¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹
94 (¥Ñ¥¹¥ï¡¼¥É¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÎã:
95 ¥í¡¼¥«¥ë¤Î¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë
101 .\"O function returns a pointer to a structure containing
102 .\"O the broken-out fields of the record in the group database
103 .\"O that matches the group ID
108 ¤Ë¥Þ¥Ã¥Á¤¹¤ë¥°¥ë¡¼¥×¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥¨¥ó¥È¥ê¤ò
109 Í×ÁÇËè¤Ëʬ²ò¤·¡¢³ÆÍ×ÁǤò³ÊǼ¤·¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
112 .\"O .BR getgrnam_r ()
114 .\"O .BR getgrgid_r ()
115 .\"O functions obtain the same information, but store the retrieved
118 .\"O in the space pointed to by
123 ´Ø¿ô¤Ï (¾åµ¤Î´Ø¿ô¤È) Ʊ¤¸¾ðÊó¤ò¼èÆÀ¤¹¤ë¤¬¡¢
128 ¤¬»Ø¤¹Îΰè¤Ë³ÊǼ¤¹¤ë¡£
131 .\"O structure contains pointers to strings, and these strings
132 .\"O are stored in the buffer
138 ¹½Â¤ÂΤˤÏʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬´Þ¤Þ¤ì¡¢
139 ¤³¤ì¤é¤Îʸ»úÎó¤Ï¥µ¥¤¥º
144 .\"O A pointer to the result (in case of success) or NULL (in case no entry
145 .\"O was found or an error occurred) is stored in
149 ¤Ë¤Ï·ë²Ì¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬³ÊǼ¤µ¤ì¤ë¡£
150 ¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤ä¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ë¤Ï
154 .\"O The \fIgroup\fP structure is defined in \fI<grp.h>\fP as follows:
155 \fIgroup\fP ¹½Â¤ÂΤϡ¢\fI<grp.h>\fP ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
160 .\"O char *gr_name; /* group name */
161 .\"O char *gr_passwd; /* group password */
162 .\"O gid_t gr_gid; /* group ID */
163 .\"O char **gr_mem; /* group members */
164 char *gr_name; /* ¥°¥ë¡¼¥×̾ */
165 char *gr_passwd; /* ¥°¥ë¡¼¥×¤Î¥Ð¥¹¥ï¡¼¥É */
166 gid_t gr_gid; /* ¥°¥ë¡¼¥× ID */
167 char **gr_mem; /* ¥°¥ë¡¼¥×¤Î¥á¥ó¥Ð */
172 .\"O The maximum needed size for
174 .\"O can be found using
176 .\"O with the argument
177 .\"O .BR _SC_GETGR_R_SIZE_MAX .
179 ¤ËºÇÂçɬÍפʥµ¥¤¥º¤Ï¡¢
182 .B _SC_GETGR_R_SIZE_MAX
183 ¤ò»ØÄꤷ¤Æ¼Â¹Ô¤¹¤ë¤³¤È¤Çʬ¤«¤ë¡£
184 .\"O .SH "RETURN VALUE"
190 .\"O functions return a pointer to a
192 .\"O structure, or NULL if the matching entry
193 .\"O is not found or an error occurs.
199 ¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
200 ¥Þ¥Ã¥Á¤¹¤ë¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤ä¡¢
201 ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï NULL ¤òÊÖ¤¹¡£
202 .\"O If an error occurs,
204 .\"O is set appropriately.
205 .\"O If one wants to check
207 .\"O after the call, it should be set to zero before the call.
208 ¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¾ì¹ç¡¢
213 ¤ò¥Á¥§¥Ã¥¯¤·¤¿¤¤¾ì¹ç¤Ï¡¢
214 ¸Æ¤Ó½Ð¤·¤ÎÁ°¤Ë (¤³¤ÎÃͤò) 0 ¤ËÀßÄꤷ¤Æ¤ª¤¯¤Ù¤¤Ç¤¢¤ë¡£
216 .\"O The return value may point to a static area, and may be overwritten
217 .\"O by subsequent calls to
218 .\"O .BR getgrent (3),
219 .\"O .BR getgrgid (),
221 .\"O .BR getgrnam ().
222 .\"O (Do not pass the returned pointer to
224 ÊÖ¤êÃͤÏÀÅŪ¤ÊÎΰè¤ò»Ø¤·¤Æ¤ª¤ê¡¢¤½¤Î¸å¤Î
228 ¤Î¸Æ¤Ó½Ð¤·¤Ç¾å½ñ¤¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
234 .\"O .BR getgrnam_r ()
236 .\"O .BR getgrgid_r ()
237 .\"O return zero, and set
241 .\"O If no matching group record was found,
242 .\"O these functions return 0 and store NULL in
244 .\"O In case of error, an error number is returned, and NULL is stored in
255 ¥Þ¥Ã¥Á¤¹¤ë¥°¥ë¡¼¥×¡¦¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢
259 ¥¨¥é¡¼¤Î¾ì¹ç¡¢¥¨¥é¡¼ÈÖ¹æ¤òÊÖ¤·¡¢
265 .\"O .BR 0 " or " ENOENT " or " ESRCH " or " EBADF " or " EPERM " or ... "
266 .BR 0 " ¤Þ¤¿¤Ï " ENOENT " ¤Þ¤¿¤Ï " ESRCH " ¤Þ¤¿¤Ï " EBADF " ¤Þ¤¿¤Ï " EPERM " ¤Þ¤¿¤Ï ... "
279 .\"O A signal was caught.
280 ¥·¥°¥Ê¥ë¤¬¥¥ã¥Ã¥Á¤µ¤ì¤¿¡£
287 .\"O The maximum number
288 .\"O .RB ( OPEN_MAX )
289 .\"O of files was open already in the calling process.
290 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Ë¤ª¤¤¤Æ¡¢
293 ¤Î¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¡£
296 .\"O The maximum number of files was open already in the system.
297 ¥·¥¹¥Æ¥à¾å¤Ç´û¤ËºÇÂç¿ô¤Î¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¡£
300 .\"O .\" not in POSIX
301 .\"O Insufficient memory to allocate
304 .\"O .\" to allocate the group structure, or to allocate buffers
307 ¹½Â¤ÂΤò³ä¤êÅö¤Æ¤ë¤¿¤á¤Î¥á¥â¥ê¤¬ÉÔ½½Ê¬¡£
308 .\" ¥°¥ë¡¼¥×¾ðÊó¹½Â¤ÂΤò³ä¤êÅö¤Æ¤ë¤¿¤á¡¢¤Þ¤¿¤Ï¥Ð¥Ã¥Õ¥¡¤ò³ä¤êÅö¤Æ¤ë¤¿¤á¤Î
311 .\"O Insufficient buffer space supplied.
312 Í¿¤¨¤é¤ì¤¿¥Ð¥Ã¥Õ¥¡¶õ´Ö¤¬ÉÔ½½Ê¬¤Ç¤¢¤ë¡£
317 .\"O local group database file
318 ¥í¡¼¥«¥ë¤Î¥°¥ë¡¼¥×¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë
319 .\"O .SH "CONFORMING TO"
321 SVr4, 4.3BSD, POSIX.1-2001.
324 .\"O The formulation given above under "RETURN VALUE" is from POSIX.1-2001.
325 ¾åµ¤Î¡ÖÊÖ¤êÃ͡װʲ¼¤Îµ½Ò¤Ï POSIX.1-2001 ¤Ëµò¤ë¡£
326 .\"O It does not call "not found" an error, hence does not specify what value
328 .\"O might have in this situation.
329 .\"O But that makes it impossible to recognize
331 .\"O One might argue that according to POSIX
333 .\"O should be left unchanged if an entry is not found.
334 .\"O Experiments on various
335 .\"O Unix-like systems shows that lots of different values occur in this
336 .\"O situation: 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM and probably others.
337 ¤³¤Îɸ½à¤Ï¡Ö(¥¨¥ó¥È¥ê¤¬) ¸«¤Ä¤«¤é¤Ê¤¤¤³¤È¡×¤ò¥¨¥é¡¼¤È¤·¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢
340 ¤¬¤É¤Î¤è¤¦¤ÊÃͤˤʤ뤫¤òÄê¤á¤Æ¤¤¤Ê¤¤¡£
341 ¤½¤Î¤¿¤á¡¢¥¨¥é¡¼¤òǧ¼±¤¹¤ë¤³¤È¤ÏÉÔ²Äǽ¤Ç¤¢¤ë¡£
342 POSIX ¤Ë½àµò¤·¤Æ¡¢¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤¤¾ì¹ç¤Ï
344 ¤òÊѹ¹¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤Ù¤¤Ç¤¢¤ë¡¢¤È¼çÄ¥¤¹¤ë¿Í¤â¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
345 ÍÍ¡¹¤Ê Unix ·Ï¤Î¥·¥¹¥Æ¥à¤Ç»î¤·¤Æ¤ß¤ë¤È¡¢¤½¤Î¤è¤¦¤Ê¾ì¹ç¤Ë¤Ï
346 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM ¤È¤¤¤Ã¤¿ÍÍ¡¹¤ÊÃͤ¬ÊÖ¤µ¤ì¤ë¡£
347 ¾¤ÎÃͤ¬ÊÖ¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
348 .\"O .\" more precisely:
349 .\"O .\" AIX 5.1 - gives ESRCH
350 .\"O .\" OSF1 4.0g - gives EWOULDBLOCK
351 .\"O .\" libc, glibc up to version 2.6, Irix 6.5 - give ENOENT
352 .\"O .\" glibc since version 2.7 - give 0
353 .\"O .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 - give EPERM
354 .\"O .\" SunOS 5.8 - gives EBADF
355 .\"O .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 - give 0
357 .\" AIX 5.1 ¤Ï ESRCH ¤òÊÖ¤¹¡£
358 .\" OSF1 4.0g ¤Ï EWOULDBLOCK ¤òÊÖ¤¹¡£
359 .\" libc, glibc (¥Ð¡¼¥¸¥ç¥ó 2.6 ¤Þ¤Ç), Irix 6.5 ¤Ï ENOENT ¤òÊÖ¤¹¡£
360 .\" glibc (¥Ð¡¼¥¸¥ç¥ó 2.7 °Ê¹ß) ¤Ï 0 ¤òÊÖ¤¹¡£
361 .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 ¤Ï EPERM ¤òÊÖ¤¹¡£
362 .\" SunOS 5.8 ¤Ï EBADF ¤òÊÖ¤¹¡£
363 .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 ¤Ï 0 ¤òÊÖ¤¹¡£