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)):
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 要素毎に分解し、各要素を格納した構造体へのポインタを返す
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 関数は (上記の関数と) 同じ情報を取得するが、
133 .\"O structure contains pointers to strings, and these strings
134 .\"O are stored in the buffer
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
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 .
184 .B _SC_GETGR_R_SIZE_MAX
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.
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.
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
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 マッチするグループ・エントリが見つからなかった場合には、
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.
289 .\"O The maximum number
290 .\"O .RB ( OPEN_MAX )
291 .\"O of files was open already in the calling process.
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
310 .\" グループ情報構造体を割り当てるため、またはバッファを割り当てるための
313 .\"O Insufficient buffer space supplied.
319 .\"O local group database file
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 この標準は「(エントリが) 見つからないこと」をエラーとしていないので、
343 そのため、エラーを認識することは不可能である。
344 POSIX に準拠して、エントリが見つからない場合は
346 を変更しないようにすべきである、と主張する人もいるかもしれない。
347 様々な UNIX 系のシステムで試してみると、そのような場合には
348 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM といった様々な値が返される。
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 を返す。