.\" Hey Emacs! This file is -*- nroff -*- source. .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu) .\" Modified 2003-11-15 by aeb .\" .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka .\" all rights reserved. .\" Translated 1997-12-19, HIROFUMI Nishizuka .\" Updated & Modefied 1999-02-26, Shouichi Saito .\" Updated & Modified 2004-06-05, Yuichi SATO .\" Updated & Modified 2005-09-06, Akihiro MOTOKI .\" Updated 2008-12-24, Akihiro MOTOKI, LDP v3.14 .\" .TH GETGRNAM 3 2009-03-30 "" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O getgrnam, getgrnam_r, getgrgid, getgrgid_r \- get group file entry getgrnam, getgrnam_r, getgrgid, getgrgid_r \- グループファイルエントリの取り出し .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .B #include .sp .BI "struct group *getgrnam(const char *" name ); .sp .BI "struct group *getgrgid(gid_t " gid ); .sp .BI "int getgrnam_r(const char *" name ", struct group *" grp , .br .BI " char *" buf ", size_t " buflen ", struct group **" result ); .sp .BI "int getgrgid_r(gid_t " gid ", struct group *" grp , .br .BI " char *" buf ", size_t " buflen ", struct group **" result ); .fi .sp .in -4n .\"O Feature Test Macro Requirements for glibc (see .\"O .BR feature_test_macros (7)): glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .ad l .in .sp .BR getgrnam_r (), .BR getgrgid_r (): .RS 4 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE || _POSIX_SOURCE .RE .ad b .\"O .SH DESCRIPTION .SH 説明 .\"O The .\"O .BR getgrnam () .\"O function returns a pointer to a structure containing .\"O the broken-out fields of the record in the group database .\"O (e.g., the local group file .\"O .IR /etc/group , .\"O NIS, and LDAP) .\"O that matches the group name .\"O .IR name . .BR getgrnam () 関数は、グループ名 .I name にマッチするグループ・データベースのエントリを 要素毎に分解し、各要素を格納した構造体へのポインタを返す (パスワード・データベースの例: ローカルのグループファイル .IR /etc/group , NIS, LDAP)。 .PP .\"O The .\"O .BR getgrgid () .\"O function returns a pointer to a structure containing .\"O the broken-out fields of the record in the group database .\"O that matches the group ID .\"O .IR gid . .BR getgrgid () 関数は、グループ ID .I uid にマッチするグループ・データベースのエントリを 要素毎に分解し、各要素を格納した構造体へのポインタを返す。 .PP .\"O The .\"O .BR getgrnam_r () .\"O and .\"O .BR getgrgid_r () .\"O functions obtain the same information, but store the retrieved .\"O .I group .\"O structure .\"O in the space pointed to by .\"O .IR grp . .BR getgrnam_r () と .BR getgrgid_r () 関数は (上記の関数と) 同じ情報を取得するが、 取得した .I group 構造体を .I grp が指す領域に格納する。 .\"O This .\"O .I group .\"O structure contains pointers to strings, and these strings .\"O are stored in the buffer .\"O .I buf .\"O of size .\"O .IR buflen . この .I group 構造体には文字列へのポインタが含まれ、 これらの文字列はサイズ .I buflen のバッファ .I buf に格納される。 .\"O A pointer to the result (in case of success) or NULL (in case no entry .\"O was found or an error occurred) is stored in .\"O .IR *result . 成功した場合 .I *gbufp には結果へのポインタが格納される。 エントリが見つからなかった場合やエラーが発生した場合には .I *result には NULL が入る。 .PP .\"O The \fIgroup\fP structure is defined in \fI\fP as follows: \fIgroup\fP 構造体は、\fI\fP で以下のように定義されている: .sp .in +4n .nf struct group { .\"O char *gr_name; /* group name */ .\"O char *gr_passwd; /* group password */ .\"O gid_t gr_gid; /* group ID */ .\"O char **gr_mem; /* group members */ char *gr_name; /* グループ名 */ char *gr_passwd; /* グループのバスワード */ gid_t gr_gid; /* グループ ID */ char **gr_mem; /* グループのメンバ */ }; .fi .in .PP .\"O The maximum needed size for .\"O .I buf .\"O can be found using .\"O .BR sysconf (3) .\"O with the argument .\"O .BR _SC_GETGR_R_SIZE_MAX . .I buf に最大必要なサイズは、 .BR sysconf (3) に引き数 .B _SC_GETGR_R_SIZE_MAX を指定して実行することで分かる。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O The .\"O .BR getgrnam () .\"O and .\"O .BR getgrgid () .\"O functions return a pointer to a .\"O .I group .\"O structure, or NULL if the matching entry .\"O is not found or an error occurs. .BR getgrnam () と .BR getgrgid () 関数は、 .I group 構造体へのポインタを返す。 マッチするエントリが見つからなかった場合や、 エラーが発生した場合は NULL を返す。 .\"O If an error occurs, .\"O .I errno .\"O is set appropriately. .\"O If one wants to check .\"O .I errno .\"O after the call, it should be set to zero before the call. エラーが起こった場合、 .I errno が適切に設定される。 呼び出しの後で .I errno をチェックしたい場合は、 呼び出しの前に (この値を) 0 に設定しておくべきである。 .LP .\"O The return value may point to a static area, and may be overwritten .\"O by subsequent calls to .\"O .BR getgrent (3), .\"O .BR getgrgid (), .\"O or .\"O .BR getgrnam (). .\"O (Do not pass the returned pointer to .\"O .BR free (3).) 返り値は静的な領域を指しており、その後の .BR getgrent (3), .BR getgrgid (), .BR getgrnam () の呼び出しで上書きされるかもしれない。 (返されたポインタを .BR free (3) に渡さないこと。) .LP .\"O On success, .\"O .BR getgrnam_r () .\"O and .\"O .BR getgrgid_r () .\"O return zero, and set .\"O .IR *result .\"O to .\"O .IR grp . .\"O If no matching group record was found, .\"O these functions return 0 and store NULL in .\"O .IR *result . .\"O In case of error, an error number is returned, and NULL is stored in .\"O .IR *result . 成功すると、 .BR getgrnam_r () と .BR getgrgid_r () は 0 を返し、 .I *result に .I grp を設定する。 マッチするグループ・エントリが見つからなかった場合には、 0 を返し、 .I *result に NULL を設定する。 エラーの場合、エラー番号を返し、 .I *result に NULL を設定する。 .\"O .SH ERRORS .SH エラー .TP .\"O .BR 0 " or " ENOENT " or " ESRCH " or " EBADF " or " EPERM " or ... " .BR 0 " または " ENOENT " または " ESRCH " または " EBADF " または " EPERM " または ... " .\"O The given .\"O .I name .\"O or .\"O .I gid .\"O was not found. 指定された .I name または .I gid が見つからなかった。 .TP .B EINTR .\"O A signal was caught. シグナルがキャッチされた。 .TP .B EIO .\"O I/O error. I/O エラー。 .TP .B EMFILE .\"O The maximum number .\"O .RB ( OPEN_MAX ) .\"O of files was open already in the calling process. 呼び出したプロセスにおいて、 既に最大数 .RB ( OPEN_MAX ) のファイルがオープンされている。 .TP .B ENFILE .\"O The maximum number of files was open already in the system. システム上で既に最大数のファイルがオープンされている。 .TP .B ENOMEM .\"O .\" not in POSIX .\"O Insufficient memory to allocate .\"O .I group .\"O structure. .\"O .\" to allocate the group structure, or to allocate buffers .\" POSIX にはない .I group 構造体を割り当てるためのメモリが不十分。 .\" グループ情報構造体を割り当てるため、またはバッファを割り当てるための .TP .B ERANGE .\"O Insufficient buffer space supplied. 与えられたバッファ空間が不十分である。 .\"O .SH FILES .SH ファイル .TP .I /etc/group .\"O local group database file ローカルのグループ・データベースファイル .\"O .SH "CONFORMING TO" .SH 準拠 SVr4, 4.3BSD, POSIX.1-2001. .\"O .SH NOTES .SH 注意 .\"O The formulation given above under "RETURN VALUE" is from POSIX.1-2001. 上記の「返り値」以下の記述は POSIX.1-2001 に拠る。 .\"O It does not call "not found" an error, hence does not specify what value .\"O .I errno .\"O might have in this situation. .\"O But that makes it impossible to recognize .\"O errors. .\"O One might argue that according to POSIX .\"O .I errno .\"O should be left unchanged if an entry is not found. .\"O Experiments on various .\"O UNIX-like systems shows that lots of different values occur in this .\"O situation: 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM and probably others. この標準は「(エントリが) 見つからないこと」をエラーとしていないので、 そのような場合に .I errno がどのような値になるかを定めていない。 そのため、エラーを認識することは不可能である。 POSIX に準拠して、エントリが見つからない場合は .I errno を変更しないようにすべきである、と主張する人もいるかもしれない。 様々な UNIX 系のシステムで試してみると、そのような場合には 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM といった様々な値が返される。 他の値が返されるかもしれない。 .\"O .\" more precisely: .\"O .\" AIX 5.1 - gives ESRCH .\"O .\" OSF1 4.0g - gives EWOULDBLOCK .\"O .\" libc, glibc up to version 2.6, Irix 6.5 - give ENOENT .\"O .\" glibc since version 2.7 - give 0 .\"O .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 - give EPERM .\"O .\" SunOS 5.8 - gives EBADF .\"O .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 - give 0 .\" より正確には: .\" AIX 5.1 は ESRCH を返す。 .\" OSF1 4.0g は EWOULDBLOCK を返す。 .\" libc, glibc (バージョン 2.6 まで), Irix 6.5 は ENOENT を返す。 .\" glibc (バージョン 2.7 以降) は 0 を返す。 .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 は EPERM を返す。 .\" SunOS 5.8 は EBADF を返す。 .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 は 0 を返す。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR endgrent (3), .BR fgetgrent (3), .BR getgrent (3), .BR getpwnam (3), .BR setgrent (3), .BR group (5)