OSDN Git Service

Update releases for LDP v3.76
[linuxjm/LDP_man-pages.git] / release / man3 / getgrnam.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\"
30 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
31 .\" Modified 2003-11-15 by aeb
32 .\"
33 .\"*******************************************************************
34 .\"
35 .\" This file was generated with po4a. Translate the source file.
36 .\"
37 .\"*******************************************************************
38 .\"
39 .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka
40 .\"     all rights reserved.
41 .\" Translated 1997-12-19, HIROFUMI Nishizuka <nishi@rpts.cl.nec.co.jp>
42 .\" Updated & Modefied 1999-02-26, Shouichi Saito
43 .\" Updated & Modified 2004-06-05, Yuichi SATO <ysato444@yahoo.co.jp>
44 .\" Updated & Modified 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
45 .\" Updated 2008-12-24, Akihiro MOTOKI, LDP v3.14
46 .\" Updated 2012-05-01, Akihiro MOTOKI <amotoki@gmail.com>
47 .\" Updated 2013-07-17, Akihiro MOTOKI <amotoki@gmail.com>
48 .\" Updated 2013-08-16, Akihiro MOTOKI <amotoki@gmail.com>
49 .\"
50 .TH GETGRNAM 3 2014\-08\-19 "" "Linux Programmer's Manual"
51 .SH 名前
52 getgrnam, getgrnam_r, getgrgid, getgrgid_r \- グループファイルエントリの取り出し
53 .SH 書式
54 .nf
55 \fB#include <sys/types.h>\fP
56 \fB#include <grp.h>\fP
57 .sp
58 \fBstruct group *getgrnam(const char *\fP\fIname\fP\fB);\fP
59 .sp
60 \fBstruct group *getgrgid(gid_t \fP\fIgid\fP\fB);\fP
61 .sp
62 \fBint getgrnam_r(const char *\fP\fIname\fP\fB, struct group *\fP\fIgrp\fP\fB,\fP
63 .br
64 \fB          char *\fP\fIbuf\fP\fB, size_t \fP\fIbuflen\fP\fB, struct group **\fP\fIresult\fP\fB);\fP
65 .sp
66 \fBint getgrgid_r(gid_t \fP\fIgid\fP\fB, struct group *\fP\fIgrp\fP\fB,\fP
67 .br
68 \fB          char *\fP\fIbuf\fP\fB, size_t \fP\fIbuflen\fP\fB, struct group **\fP\fIresult\fP\fB);\fP
69 .fi
70 .sp
71 .in -4n
72 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
73 .ad l
74 .in
75 .sp
76 \fBgetgrnam_r\fP(), \fBgetgrgid_r\fP():
77 .RS 4
78 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE
79 || _POSIX_SOURCE
80 .RE
81 .ad b
82 .SH 説明
83 \fBgetgrnam\fP()  関数は、グループ名 \fIname\fP にマッチするグループ・データベースのエントリを
84 要素毎に分解し、各要素を格納した構造体へのポインタを返す (パスワード・データベースの例: ローカルのグループファイル \fI/etc/group\fP,
85 NIS, LDAP)。
86 .PP
87 \fBgetgrgid\fP()  関数は、グループ ID \fIuid\fP にマッチするグループ・データベースのエントリを
88 要素毎に分解し、各要素を格納した構造体へのポインタを返す。
89 .PP
90 \fIgroup\fP 構造体は \fI<grp.h>\fP で以下のように定義されている:
91 .sp
92 .in +4n
93 .nf
94 struct group {
95     char   *gr_name;        /* グループ名 */
96     char   *gr_passwd;      /* グループのパスワード */
97     gid_t   gr_gid;         /* グループ ID */
98     char  **gr_mem;         /* グループのメンバ名へのポインター
99                                の配列 (配列はヌルで終端する) */
100 };
101 .fi
102 .in
103 .PP
104 この構造体のフィールドの詳細は \fBgroup\fP(5)  を参照のこと。
105 .PP
106 \fBgetgrnam_r\fP() と \fBgetgrgid_r\fP() 関数は、それぞれ \fBgetgrnam\fP() と
107 \fBgetgrgid\fP() と同じ情報を取得するが、取得した \fIgroup\fP 構造体を
108 \fIgrp\fP が指す領域に格納する。\fIgroup\fP 構造体のメンバーが指す文字列は、
109 サイズ \fIbuflen\fP のバッファ \fIbuf\fP に格納される。成功した場合
110 \fI*gbufp\fP には結果へのポインタが格納される。エントリが見つからなかった
111 場合やエラーが発生した場合には \fI*result\fP には NULL が入る。
112 .PP
113 呼び出し
114
115     sysconf(_SC_GETGR_R_SIZE_MAX)
116
117 は、 \fIerrno\fP を変更せずに \-1 を返すか、 \fIbuf\fP の初期サイズの推奨値を
118 返す。(このサイズが小さすぎる場合、呼び出しは \fBERANGE\fP で失敗し、この
119 場合には呼び出し側はバッファを大きくしてから再度呼び出すことができる。)
120 .SH 返り値
121 \fBgetgrnam\fP()  と \fBgetgrgid\fP()  関数は、 \fIgroup\fP 構造体へのポインタを返す。
122 マッチするエントリが見つからなかった場合や、 エラーが発生した場合は NULL を返す。 エラーが起こった場合、 \fIerrno\fP が適切に設定される。
123 呼び出しの後で \fIerrno\fP をチェックしたい場合は、 呼び出しの前に (この値を) 0 に設定しておくべきである。
124 .LP
125 返り値は静的な領域を指しており、その後の \fBgetgrent\fP(3), \fBgetgrgid\fP(), \fBgetgrnam\fP()
126 の呼び出しで上書きされるかもしれない。 (返されたポインタを \fBfree\fP(3)  に渡さないこと。)
127 .LP
128 成功すると、 \fBgetgrnam_r\fP()  と \fBgetgrgid_r\fP()  は 0 を返し、 \fI*result\fP に \fIgrp\fP
129 を設定する。 マッチするグループ・エントリが見つからなかった場合には、 0 を返し、 \fI*result\fP に NULL を設定する。
130 エラーの場合、エラー番号を返し、 \fI*result\fP に NULL を設定する。
131 .SH エラー
132 .TP 
133 \fB0\fP または \fBENOENT\fP または \fBESRCH\fP または \fBEBADF\fP または \fBEPERM\fP または ... 
134 指定された \fIname\fP または \fIgid\fP が見つからなかった。
135 .TP 
136 \fBEINTR\fP
137 シグナルが捕捉された。
138 .TP 
139 \fBEIO\fP
140 I/O エラー。
141 .TP 
142 \fBEMFILE\fP
143 呼び出し元プロセスがオープンしているファイル数が すでに上限 (\fBOPEN_MAX\fP)  であった。
144 .TP 
145 \fBENFILE\fP
146 システムでオープンされているファイル数がすでに上限であった。
147 .TP 
148 \fBENOMEM\fP
149 .\" not in POSIX
150 .\" to allocate the group structure, or to allocate buffers
151 \fIgroup\fP 構造体を割り当てるためのメモリが不十分。
152 .TP 
153 \fBERANGE\fP
154 与えられたバッファ空間が不十分である。
155 .SH ファイル
156 .TP 
157 \fI/etc/group\fP
158 ローカルのグループ・データベースファイル
159 .SH 属性
160 .SS "マルチスレッディング (pthreads(7) 参照)"
161 関数 \fBgetgrnam\fP() と \fBgetgrgid\fP() はスレッドセーフではない。
162 .LP
163 関数 \fBgetgrnam_r\fP() と \fBgetgrgid_r\fP() はスレッドセーフである。
164 .SH 準拠
165 SVr4, 4.3BSD, POSIX.1\-2001.
166 .SH 注意
167 .\" more precisely:
168 .\" AIX 5.1 - gives ESRCH
169 .\" OSF1 4.0g - gives EWOULDBLOCK
170 .\" libc, glibc up to version 2.6, Irix 6.5 - give ENOENT
171 .\" glibc since version 2.7 - give 0
172 .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 - give EPERM
173 .\" SunOS 5.8 - gives EBADF
174 .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 - give 0
175 上記の「返り値」以下の記述は POSIX.1\-2001 に拠る。 この標準は「(エントリが) 見つからないこと」をエラーとしていないので、
176 そのような場合に \fIerrno\fP がどのような値になるかを定めていない。 そのため、エラーを認識することは不可能である。 POSIX
177 に準拠して、エントリが見つからない場合は \fIerrno\fP を変更しないようにすべきである、と主張する人もいるかもしれない。 様々な UNIX
178 系のシステムで試してみると、そのような場合には 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM
179 といった様々な値が返される。 他の値が返されるかもしれない。
180 .SH 関連項目
181 \fBendgrent\fP(3), \fBfgetgrent\fP(3), \fBgetgrent\fP(3), \fBgetpwnam\fP(3),
182 \fBsetgrent\fP(3), \fBgroup\fP(5)
183 .SH この文書について
184 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.76 の一部
185 である。プロジェクトの説明とバグ報告に関する情報は
186 http://www.kernel.org/doc/man\-pages/ に書かれている。