OSDN Git Service

(split) LDP: Restore and add Copyrights for draft pages
[linuxjm/LDP_man-pages.git] / draft / 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 2013\-07\-22 "" "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 .fi
101 .in
102 .PP
103 この構造体のフィールドの詳細は \fBgroup\fP(5)  を参照のこと。
104 .PP
105 \fBgetgrnam_r\fP() と \fBgetgrgid_r\fP() 関数は、それぞれ \fBgetgrnam\fP() と
106 \fBgetgrgid\fP() と同じ情報を取得するが、取得した \fIgroup\fP 構造体を
107 \fIgrp\fP が指す領域に格納する。\fIgroup\fP 構造体のメンバーが指す文字列は、
108 サイズ \fIbuflen\fP のバッファ \fIbuf\fP に格納される。成功した場合
109 \fI*gbufp\fP には結果へのポインタが格納される。エントリが見つからなかった
110 場合やエラーが発生した場合には \fI*result\fP には NULL が入る。
111 .PP
112 呼び出し
113
114     sysconf(_SC_GETGR_R_SIZE_MAX)
115
116 は、 \fIerrno\fP を変更せずに \-1 を返すか、 \fIbuf\fP の初期サイズの推奨値を
117 返す。(このサイズが小さすぎる場合、呼び出しは \fBERANGE\fP で失敗し、この
118 場合には呼び出し側はバッファを大きくしてから再度呼び出すことができる。)
119 .SH 返り値
120 \fBgetgrnam\fP()  と \fBgetgrgid\fP()  関数は、 \fIgroup\fP 構造体へのポインタを返す。
121 マッチするエントリが見つからなかった場合や、 エラーが発生した場合は NULL を返す。 エラーが起こった場合、 \fIerrno\fP が適切に設定される。
122 呼び出しの後で \fIerrno\fP をチェックしたい場合は、 呼び出しの前に (この値を) 0 に設定しておくべきである。
123 .LP
124 返り値は静的な領域を指しており、その後の \fBgetgrent\fP(3), \fBgetgrgid\fP(), \fBgetgrnam\fP()
125 の呼び出しで上書きされるかもしれない。 (返されたポインタを \fBfree\fP(3)  に渡さないこと。)
126 .LP
127 成功すると、 \fBgetgrnam_r\fP()  と \fBgetgrgid_r\fP()  は 0 を返し、 \fI*result\fP に \fIgrp\fP
128 を設定する。 マッチするグループ・エントリが見つからなかった場合には、 0 を返し、 \fI*result\fP に NULL を設定する。
129 エラーの場合、エラー番号を返し、 \fI*result\fP に NULL を設定する。
130 .SH エラー
131 .TP 
132 \fB0\fP または \fBENOENT\fP または \fBESRCH\fP または \fBEBADF\fP または \fBEPERM\fP または ... 
133 指定された \fIname\fP または \fIgid\fP が見つからなかった。
134 .TP 
135 \fBEINTR\fP
136 シグナルが捕捉された。
137 .TP 
138 \fBEIO\fP
139 I/O エラー。
140 .TP 
141 \fBEMFILE\fP
142 呼び出し元プロセスがオープンしているファイル数が すでに上限 (\fBOPEN_MAX\fP)  であった。
143 .TP 
144 \fBENFILE\fP
145 システムでオープンされているファイル数がすでに上限であった。
146 .TP 
147 \fBENOMEM\fP
148 .\" not in POSIX
149 .\" to allocate the group structure, or to allocate buffers
150 \fIgroup\fP 構造体を割り当てるためのメモリが不十分。
151 .TP 
152 \fBERANGE\fP
153 与えられたバッファ空間が不十分である。
154 .SH ファイル
155 .TP 
156 \fI/etc/group\fP
157 ローカルのグループ・データベースファイル
158 .SH 属性
159 .SS "マルチスレッディング (pthreads(7) 参照)"
160 関数 \fBgetgrnam\fP() と \fBgetgrgid\fP() はスレッドセーフではない。
161 .LP
162 関数 \fBgetgrnam_r\fP() と \fBgetgrgid_r\fP() はスレッドセーフである。
163 .SH 準拠
164 SVr4, 4.3BSD, POSIX.1\-2001.
165 .SH 注意
166 .\" more precisely:
167 .\" AIX 5.1 - gives ESRCH
168 .\" OSF1 4.0g - gives EWOULDBLOCK
169 .\" libc, glibc up to version 2.6, Irix 6.5 - give ENOENT
170 .\" glibc since version 2.7 - give 0
171 .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 - give EPERM
172 .\" SunOS 5.8 - gives EBADF
173 .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 - give 0
174 上記の「返り値」以下の記述は POSIX.1\-2001 に拠る。 この標準は「(エントリが) 見つからないこと」をエラーとしていないので、
175 そのような場合に \fIerrno\fP がどのような値になるかを定めていない。 そのため、エラーを認識することは不可能である。 POSIX
176 に準拠して、エントリが見つからない場合は \fIerrno\fP を変更しないようにすべきである、と主張する人もいるかもしれない。 様々な UNIX
177 系のシステムで試してみると、そのような場合には 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM
178 といった様々な値が返される。 他の値が返されるかもしれない。
179 .SH 関連項目
180 \fBendgrent\fP(3), \fBfgetgrent\fP(3), \fBgetgrent\fP(3), \fBgetpwnam\fP(3),
181 \fBsetgrent\fP(3), \fBgroup\fP(5)
182 .SH この文書について
183 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
184 である。プロジェクトの説明とバグ報告に関する情報は
185 http://www.kernel.org/doc/man\-pages/ に書かれている。