OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[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)