OSDN Git Service

(split) LDP: Addresses fuzzy strings in 3.53
[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 .TH GETGRNAM 3 2013\-07\-22 "" "Linux Programmer's Manual"
39 .SH 名前
40 getgrnam, getgrnam_r, getgrgid, getgrgid_r \- グループファイルエントリの取り出し
41 .SH 書式
42 .nf
43 \fB#include <sys/types.h>\fP
44 \fB#include <grp.h>\fP
45 .sp
46 \fBstruct group *getgrnam(const char *\fP\fIname\fP\fB);\fP
47 .sp
48 \fBstruct group *getgrgid(gid_t \fP\fIgid\fP\fB);\fP
49 .sp
50 \fBint getgrnam_r(const char *\fP\fIname\fP\fB, struct group *\fP\fIgrp\fP\fB,\fP
51 .br
52 \fB          char *\fP\fIbuf\fP\fB, size_t \fP\fIbuflen\fP\fB, struct group **\fP\fIresult\fP\fB);\fP
53 .sp
54 \fBint getgrgid_r(gid_t \fP\fIgid\fP\fB, struct group *\fP\fIgrp\fP\fB,\fP
55 .br
56 \fB          char *\fP\fIbuf\fP\fB, size_t \fP\fIbuflen\fP\fB, struct group **\fP\fIresult\fP\fB);\fP
57 .fi
58 .sp
59 .in -4n
60 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
61 .ad l
62 .in
63 .sp
64 \fBgetgrnam_r\fP(), \fBgetgrgid_r\fP():
65 .RS 4
66 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE
67 || _POSIX_SOURCE
68 .RE
69 .ad b
70 .SH 説明
71 \fBgetgrnam\fP()  関数は、グループ名 \fIname\fP にマッチするグループ・データベースのエントリを
72 要素毎に分解し、各要素を格納した構造体へのポインタを返す (パスワード・データベースの例: ローカルのグループファイル \fI/etc/group\fP,
73 NIS, LDAP)。
74 .PP
75 \fBgetgrgid\fP()  関数は、グループ ID \fIuid\fP にマッチするグループ・データベースのエントリを
76 要素毎に分解し、各要素を格納した構造体へのポインタを返す。
77 .PP
78 \fIgroup\fP 構造体は \fI<grp.h>\fP で以下のように定義されている:
79 .sp
80 .in +4n
81 .nf
82 struct group {
83     char   *gr_name;       /* グループ名 */
84     char   *gr_passwd;     /* グループのパスワード */
85     gid_t   gr_gid;        /* グループ ID */
86     char  **gr_mem;        /* グループのメンバ */
87 };
88 .fi
89 .in
90 .PP
91 この構造体のフィールドの詳細は \fBgroup\fP(5)  を参照のこと。
92 .PP
93 \fBgetgrnam_r\fP() と \fBgetgrgid_r\fP() 関数は、それぞれ \fBgetgrnam\fP() と
94 \fBgetgrgid\fP() と同じ情報を取得するが、取得した \fIgroup\fP 構造体を
95 \fIgrp\fP が指す領域に格納する。\fIgroup\fP 構造体のメンバーが指す文字列は、
96 サイズ \fIbuflen\fP のバッファ \fIbuf\fP に格納される。成功した場合
97 \fI*gbufp\fP には結果へのポインタが格納される。エントリが見つからなかった
98 場合やエラーが発生した場合には \fI*result\fP には NULL が入る。
99 .PP
100 呼び出し
101
102     sysconf(_SC_GETGR_R_SIZE_MAX)
103
104 は、 \fIerrno\fP を変更せずに \-1 を返すか、 \fIbuf\fP の初期サイズの推奨値を
105 返す。(このサイズが小さすぎる場合、呼び出しは \fBERANGE\fP で失敗し、この
106 場合には呼び出し側はバッファを大きくしてから再度呼び出すことができる。)
107 .SH 返り値
108 \fBgetgrnam\fP()  と \fBgetgrgid\fP()  関数は、 \fIgroup\fP 構造体へのポインタを返す。
109 マッチするエントリが見つからなかった場合や、 エラーが発生した場合は NULL を返す。 エラーが起こった場合、 \fIerrno\fP が適切に設定される。
110 呼び出しの後で \fIerrno\fP をチェックしたい場合は、 呼び出しの前に (この値を) 0 に設定しておくべきである。
111 .LP
112 返り値は静的な領域を指しており、その後の \fBgetgrent\fP(3), \fBgetgrgid\fP(), \fBgetgrnam\fP()
113 の呼び出しで上書きされるかもしれない。 (返されたポインタを \fBfree\fP(3)  に渡さないこと。)
114 .LP
115 成功すると、 \fBgetgrnam_r\fP()  と \fBgetgrgid_r\fP()  は 0 を返し、 \fI*result\fP に \fIgrp\fP
116 を設定する。 マッチするグループ・エントリが見つからなかった場合には、 0 を返し、 \fI*result\fP に NULL を設定する。
117 エラーの場合、エラー番号を返し、 \fI*result\fP に NULL を設定する。
118 .SH エラー
119 .TP 
120 \fB0\fP または \fBENOENT\fP または \fBESRCH\fP または \fBEBADF\fP または \fBEPERM\fP または ... 
121 指定された \fIname\fP または \fIgid\fP が見つからなかった。
122 .TP 
123 \fBEINTR\fP
124 シグナルが捕捉された。
125 .TP 
126 \fBEIO\fP
127 I/O エラー。
128 .TP 
129 \fBEMFILE\fP
130 呼び出し元プロセスがオープンしているファイル数が すでに上限 (\fBOPEN_MAX\fP)  であった。
131 .TP 
132 \fBENFILE\fP
133 システムでオープンされているファイル数がすでに上限であった。
134 .TP 
135 \fBENOMEM\fP
136 .\" not in POSIX
137 .\" to allocate the group structure, or to allocate buffers
138 \fIgroup\fP 構造体を割り当てるためのメモリが不十分。
139 .TP 
140 \fBERANGE\fP
141 与えられたバッファ空間が不十分である。
142 .SH ファイル
143 .TP 
144 \fI/etc/group\fP
145 ローカルのグループ・データベースファイル
146 .SH 属性
147 .SS "マルチスレッディング (pthreads(7) 参照)"
148 関数 \fBgetgrnam\fP() と \fBgetgrgid\fP() はスレッドセーフではない。
149 .LP
150 関数 \fBgetgrnam_r\fP() と \fBgetgrgid_r\fP() はスレッドセーフである。
151 .SH 準拠
152 SVr4, 4.3BSD, POSIX.1\-2001.
153 .SH 注意
154 .\" more precisely:
155 .\" AIX 5.1 - gives ESRCH
156 .\" OSF1 4.0g - gives EWOULDBLOCK
157 .\" libc, glibc up to version 2.6, Irix 6.5 - give ENOENT
158 .\" glibc since version 2.7 - give 0
159 .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 - give EPERM
160 .\" SunOS 5.8 - gives EBADF
161 .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 - give 0
162 上記の「返り値」以下の記述は POSIX.1\-2001 に拠る。 この標準は「(エントリが) 見つからないこと」をエラーとしていないので、
163 そのような場合に \fIerrno\fP がどのような値になるかを定めていない。 そのため、エラーを認識することは不可能である。 POSIX
164 に準拠して、エントリが見つからない場合は \fIerrno\fP を変更しないようにすべきである、と主張する人もいるかもしれない。 様々な UNIX
165 系のシステムで試してみると、そのような場合には 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM
166 といった様々な値が返される。 他の値が返されるかもしれない。
167 .SH 関連項目
168 \fBendgrent\fP(3), \fBfgetgrent\fP(3), \fBgetgrent\fP(3), \fBgetpwnam\fP(3),
169 \fBsetgrent\fP(3), \fBgroup\fP(5)
170 .SH この文書について
171 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
172 である。プロジェクトの説明とバグ報告に関する情報は
173 http://www.kernel.org/doc/man\-pages/ に書かれている。