OSDN Git Service

(split) LDP v3.24 -> v3.29 の定型的な変更内容を反映。
[linuxjm/LDP_man-pages.git] / draft / man3 / getgrnam.3
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\"
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.
7 .\"
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.
12 .\"
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
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .\" References consulted:
25 .\"     Linux libc source code
26 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\"     386BSD man pages
28 .\"
29 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
30 .\" Modified 2003-11-15 by aeb
31 .\"
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
39 .\"
40 .TH GETGRNAM 3 2009-03-30 "" "Linux Programmer's Manual"
41 .\"O .SH NAME
42 .SH Ì¾Á°
43 .\"O getgrnam, getgrnam_r, getgrgid, getgrgid_r \- get group file entry
44 getgrnam, getgrnam_r, getgrgid, getgrgid_r \- ¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë¥¨¥ó¥È¥ê¤Î¼è¤ê½Ð¤·
45 .\"O .SH SYNOPSIS
46 .SH ½ñ¼°
47 .nf
48 .B #include <sys/types.h>
49 .B #include <grp.h>
50 .sp
51 .BI "struct group *getgrnam(const char *" name );
52 .sp
53 .BI "struct group *getgrgid(gid_t " gid );
54 .sp
55 .BI "int getgrnam_r(const char *" name ", struct group *" grp ,
56 .br
57 .BI "          char *" buf ", size_t " buflen ", struct group **" result );
58 .sp
59 .BI "int getgrgid_r(gid_t " gid ", struct group *" grp ,
60 .br
61 .BI "          char *" buf ", size_t " buflen ", struct group **" result );
62 .fi
63 .sp
64 .in -4n
65 .\"O Feature Test Macro Requirements for glibc (see
66 .\"O .BR feature_test_macros (7)):
67 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
68 .RB ( feature_test_macros (7)
69 »²¾È):
70 .ad l
71 .in
72 .sp
73 .BR getgrnam_r (),
74 .BR getgrgid_r ():
75 .RS 4
76 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE ||
77 _SVID_SOURCE || _POSIX_SOURCE
78 .RE
79 .ad b
80 .\"O .SH DESCRIPTION
81 .SH ÀâÌÀ
82 .\"O The
83 .\"O .BR getgrnam ()
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
87 .\"O .IR /etc/group ,
88 .\"O NIS, and LDAP)
89 .\"O that matches the group name
90 .\"O .IR name .
91 .BR getgrnam ()
92 ´Ø¿ô¤Ï¡¢¥°¥ë¡¼¥×̾
93 .I name
94 ¤Ë¥Þ¥Ã¥Á¤¹¤ë¥°¥ë¡¼¥×¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥¨¥ó¥È¥ê¤ò
95 Í×ÁÇËè¤Ëʬ²ò¤·¡¢³ÆÍ×ÁǤò³ÊǼ¤·¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹
96 (¥Ñ¥¹¥ï¡¼¥É¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÎã:
97 ¥í¡¼¥«¥ë¤Î¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë
98 .IR /etc/group ,
99 NIS, LDAP)¡£
100 .PP
101 .\"O The
102 .\"O .BR getgrgid ()
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
106 .\"O .IR gid .
107 .BR getgrgid ()
108 ´Ø¿ô¤Ï¡¢¥°¥ë¡¼¥× ID
109 .I uid
110 ¤Ë¥Þ¥Ã¥Á¤¹¤ë¥°¥ë¡¼¥×¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥¨¥ó¥È¥ê¤ò
111 Í×ÁÇËè¤Ëʬ²ò¤·¡¢³ÆÍ×ÁǤò³ÊǼ¤·¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
112 .PP
113 .\"O The
114 .\"O .BR getgrnam_r ()
115 .\"O and
116 .\"O .BR getgrgid_r ()
117 .\"O functions obtain the same information, but store the retrieved
118 .\"O .I group
119 .\"O structure
120 .\"O in the space pointed to by
121 .\"O .IR grp .
122 .BR getgrnam_r ()
123 ¤È
124 .BR getgrgid_r ()
125 ´Ø¿ô¤Ï (¾åµ­¤Î´Ø¿ô¤È) Æ±¤¸¾ðÊó¤ò¼èÆÀ¤¹¤ë¤¬¡¢
126 ¼èÆÀ¤·¤¿
127 .I group
128 ¹½Â¤ÂΤò
129 .I grp
130 ¤¬»Ø¤¹Îΰè¤Ë³ÊǼ¤¹¤ë¡£
131 .\"O This
132 .\"O .I group
133 .\"O structure contains pointers to strings, and these strings
134 .\"O are stored in the buffer
135 .\"O .I buf
136 .\"O of size
137 .\"O .IR buflen .
138 ¤³¤Î
139 .I group
140 ¹½Â¤ÂΤˤÏʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬´Þ¤Þ¤ì¡¢
141 ¤³¤ì¤é¤Îʸ»úÎó¤Ï¥µ¥¤¥º
142 .I buflen
143 ¤Î¥Ð¥Ã¥Õ¥¡
144 .I buf
145 ¤Ë³ÊǼ¤µ¤ì¤ë¡£
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
148 .\"O .IR *result .
149 À®¸ù¤·¤¿¾ì¹ç
150 .I *gbufp
151 ¤Ë¤Ï·ë²Ì¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬³ÊǼ¤µ¤ì¤ë¡£
152 ¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤ä¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ë¤Ï
153 .I *result
154 ¤Ë¤Ï NULL ¤¬Æþ¤ë¡£
155 .PP
156 .\"O The \fIgroup\fP structure is defined in \fI<grp.h>\fP as follows:
157 \fIgroup\fP ¹½Â¤ÂΤϡ¢\fI<grp.h>\fP ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
158 .sp
159 .in +4n
160 .nf
161 struct group {
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;        /* ¥°¥ë¡¼¥×¤Î¥á¥ó¥Ð */
170 };
171 .fi
172 .in
173 .PP
174 .\"O The maximum needed size for
175 .\"O .I buf
176 .\"O can be found using
177 .\"O .BR sysconf (3)
178 .\"O with the argument
179 .\"O .BR _SC_GETGR_R_SIZE_MAX .
180 .I buf
181 ¤ËºÇÂçɬÍפʥµ¥¤¥º¤Ï¡¢
182 .BR sysconf (3)
183 ¤Ë°ú¤­¿ô
184 .B _SC_GETGR_R_SIZE_MAX
185 ¤ò»ØÄꤷ¤Æ¼Â¹Ô¤¹¤ë¤³¤È¤Çʬ¤«¤ë¡£
186 .\"O .SH "RETURN VALUE"
187 .SH ÊÖ¤êÃÍ
188 .\"O The
189 .\"O .BR getgrnam ()
190 .\"O and
191 .\"O .BR getgrgid ()
192 .\"O functions return a pointer to a
193 .\"O .I group
194 .\"O structure, or NULL if the matching entry
195 .\"O is not found or an error occurs.
196 .BR getgrnam ()
197 ¤È
198 .BR getgrgid ()
199 ´Ø¿ô¤Ï¡¢
200 .I group
201 ¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
202 ¥Þ¥Ã¥Á¤¹¤ë¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤ä¡¢
203 ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï NULL ¤òÊÖ¤¹¡£
204 .\"O If an error occurs,
205 .\"O .I errno
206 .\"O is set appropriately.
207 .\"O If one wants to check
208 .\"O .I errno
209 .\"O after the call, it should be set to zero before the call.
210 ¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¾ì¹ç¡¢
211 .I errno
212 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
213 ¸Æ¤Ó½Ð¤·¤Î¸å¤Ç
214 .I errno
215 ¤ò¥Á¥§¥Ã¥¯¤·¤¿¤¤¾ì¹ç¤Ï¡¢
216 ¸Æ¤Ó½Ð¤·¤ÎÁ°¤Ë (¤³¤ÎÃͤò) 0 ¤ËÀßÄꤷ¤Æ¤ª¤¯¤Ù¤­¤Ç¤¢¤ë¡£
217 .LP
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 (),
222 .\"O or
223 .\"O .BR getgrnam ().
224 .\"O (Do not pass the returned pointer to
225 .\"O .BR free (3).)
226 ÊÖ¤êÃͤÏÀÅŪ¤ÊÎΰè¤ò»Ø¤·¤Æ¤ª¤ê¡¢¤½¤Î¸å¤Î
227 .BR getgrent (3),
228 .BR getgrgid (),
229 .BR getgrnam ()
230 ¤Î¸Æ¤Ó½Ð¤·¤Ç¾å½ñ¤­¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
231 (ÊÖ¤µ¤ì¤¿¥Ý¥¤¥ó¥¿¤ò
232 .BR free (3)
233 ¤ËÅϤµ¤Ê¤¤¤³¤È¡£)
234 .LP
235 .\"O On success,
236 .\"O .BR getgrnam_r ()
237 .\"O and
238 .\"O .BR getgrgid_r ()
239 .\"O return zero, and set
240 .\"O .IR *result
241 .\"O to
242 .\"O .IR grp .
243 .\"O If no matching group record was found,
244 .\"O these functions return 0 and store NULL in
245 .\"O .IR *result .
246 .\"O In case of error, an error number is returned, and NULL is stored in
247 .\"O .IR *result .
248 À®¸ù¤¹¤ë¤È¡¢
249 .BR getgrnam_r ()
250 ¤È
251 .BR getgrgid_r ()
252 ¤Ï 0 ¤òÊÖ¤·¡¢
253 .I *result
254 ¤Ë
255 .I grp
256 ¤òÀßÄꤹ¤ë¡£
257 ¥Þ¥Ã¥Á¤¹¤ë¥°¥ë¡¼¥×¡¦¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢
258 0 ¤òÊÖ¤·¡¢
259 .I *result
260 ¤Ë NULL ¤òÀßÄꤹ¤ë¡£
261 ¥¨¥é¡¼¤Î¾ì¹ç¡¢¥¨¥é¡¼ÈÖ¹æ¤òÊÖ¤·¡¢
262 .I *result
263 ¤Ë NULL ¤òÀßÄꤹ¤ë¡£
264 .\"O .SH ERRORS
265 .SH ¥¨¥é¡¼
266 .TP
267 .\"O .BR 0 " or " ENOENT " or " ESRCH " or " EBADF " or " EPERM " or ... "
268 .BR 0 " ¤Þ¤¿¤Ï " ENOENT " ¤Þ¤¿¤Ï " ESRCH " ¤Þ¤¿¤Ï " EBADF " ¤Þ¤¿¤Ï " EPERM " ¤Þ¤¿¤Ï ... "
269 .\"O The given
270 .\"O .I name
271 .\"O or
272 .\"O .I gid
273 .\"O was not found.
274 »ØÄꤵ¤ì¤¿
275 .I name
276 ¤Þ¤¿¤Ï
277 .I gid
278 ¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¡£
279 .TP
280 .B EINTR
281 .\"O A signal was caught.
282 ¥·¥°¥Ê¥ë¤¬¥­¥ã¥Ã¥Á¤µ¤ì¤¿¡£
283 .TP
284 .B EIO
285 .\"O I/O error.
286 I/O ¥¨¥é¡¼¡£
287 .TP
288 .B EMFILE
289 .\"O The maximum number
290 .\"O .RB ( OPEN_MAX )
291 .\"O of files was open already in the calling process.
292 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Ë¤ª¤¤¤Æ¡¢
293 ´û¤ËºÇÂç¿ô
294 .RB ( OPEN_MAX )
295 ¤Î¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¡£
296 .TP
297 .B ENFILE
298 .\"O The maximum number of files was open already in the system.
299 ¥·¥¹¥Æ¥à¾å¤Ç´û¤ËºÇÂç¿ô¤Î¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¡£
300 .TP
301 .B ENOMEM
302 .\"O .\" not in POSIX
303 .\"O Insufficient memory to allocate
304 .\"O .I group
305 .\"O structure.
306 .\"O .\" to allocate the group structure, or to allocate buffers
307 .\" POSIX ¤Ë¤Ï¤Ê¤¤
308 .I group
309 ¹½Â¤ÂΤò³ä¤êÅö¤Æ¤ë¤¿¤á¤Î¥á¥â¥ê¤¬ÉÔ½½Ê¬¡£
310 .\" ¥°¥ë¡¼¥×¾ðÊó¹½Â¤ÂΤò³ä¤êÅö¤Æ¤ë¤¿¤á¡¢¤Þ¤¿¤Ï¥Ð¥Ã¥Õ¥¡¤ò³ä¤êÅö¤Æ¤ë¤¿¤á¤Î
311 .TP
312 .B ERANGE
313 .\"O Insufficient buffer space supplied.
314 Í¿¤¨¤é¤ì¤¿¥Ð¥Ã¥Õ¥¡¶õ´Ö¤¬ÉÔ½½Ê¬¤Ç¤¢¤ë¡£
315 .\"O .SH FILES
316 .SH ¥Õ¥¡¥¤¥ë
317 .TP
318 .I /etc/group
319 .\"O local group database file
320 ¥í¡¼¥«¥ë¤Î¥°¥ë¡¼¥×¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë
321 .\"O .SH "CONFORMING TO"
322 .SH ½àµò
323 SVr4, 4.3BSD, POSIX.1-2001.
324 .\"O .SH NOTES
325 .SH Ãí°Õ
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
329 .\"O .I errno
330 .\"O might have in this situation.
331 .\"O But that makes it impossible to recognize
332 .\"O errors.
333 .\"O One might argue that according to POSIX
334 .\"O .I errno
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 ¤³¤Îɸ½à¤Ï¡Ö(¥¨¥ó¥È¥ê¤¬) ¸«¤Ä¤«¤é¤Ê¤¤¤³¤È¡×¤ò¥¨¥é¡¼¤È¤·¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢
340 ¤½¤Î¤è¤¦¤Ê¾ì¹ç¤Ë
341 .I errno
342 ¤¬¤É¤Î¤è¤¦¤ÊÃͤˤʤ뤫¤òÄê¤á¤Æ¤¤¤Ê¤¤¡£
343 ¤½¤Î¤¿¤á¡¢¥¨¥é¡¼¤òǧ¼±¤¹¤ë¤³¤È¤ÏÉÔ²Äǽ¤Ç¤¢¤ë¡£
344 POSIX ¤Ë½àµò¤·¤Æ¡¢¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤¤¾ì¹ç¤Ï
345 .I errno
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
358 .\" ¤è¤êÀµ³Î¤Ë¤Ï:
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 ¤òÊÖ¤¹¡£
366 .\"O .SH "SEE ALSO"
367 .SH ´ØÏ¢¹àÌÜ
368 .BR endgrent (3),
369 .BR fgetgrent (3),
370 .BR getgrent (3),
371 .BR getpwnam (3),
372 .BR setgrent (3),
373 .BR group (5)