.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%LICENSE_START(VERBATIM) .\" 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. .\" %%%LICENSE_END .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" .\" Modified Sat Jul 24 19:22:14 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Mon May 27 21:37:47 1996 by Martin Schulze (joey@linux.de) .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka .\" all rights reserved. .\" Translated 1997-12-18, HIROFUMI Nishizuka .\" Updated 2005-09-06, Akihiro MOTOKI .\" .TH GETPWENT 3 2017\-09\-15 GNU "Linux Programmer's Manual" .SH 名前 getpwent, setpwent, endpwent \- パスワードファイルのエントリーの取得 .SH 書式 .nf \fB#include \fP \fB#include \fP .PP \fBstruct passwd *getpwent(void);\fP .PP \fBvoid setpwent(void);\fP .PP \fBvoid endpwent(void);\fP .fi .PP .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP .ad l \fBgetpwent\fP(), \fBsetpwent\fP(), \fBendpwent\fP(): .RS 4 .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED _XOPEN_SOURCE\ >=\ 500 || /* glibc 2.19 以降: */ _DEFAULT_SOURCE || /* glibc 2.19 以前: */ _BSD_SOURCE || _SVID_SOURCE .RE .ad b .SH 説明 \fBgetpwent\fP() 関数は、パスワードデータベースから取得したエントリーを 要素毎に分解し、各要素を格納した構造体へのポインターを返す (パスワードデータベースの例: ローカルのパスワードファイル \fI/etc/passwd\fP, NIS, LDAP)。 \fBgetpwent\fP() は、最初に呼び出された時は最初のエントリーを返し、それ以降は 呼び出される毎に次のエントリーを返す。 .PP \fBsetpwent\fP() 関数を使うと、パスワードデータベースの先頭に戻る。 .PP \fBendpwent\fP() 関数は、全ての処理が終わった後にパスワード データベースをクローズする。 .PP \fIpasswd\fP 構造体は、\fI\fP で以下のように定義されている: .PP .in +4n .EX struct passwd { char *pw_name; /* ユーザー名 */ char *pw_passwd; /* ユーザーのパスワード */ uid_t pw_uid; /* ユーザー ID */ gid_t pw_gid; /* グループ ID */ char *pw_gecos; /* ユーザー情報 */ char *pw_dir; /* ホームディレクトリ */ char *pw_shell; /* シェルプログラム */ }; .EE .in .PP この構造体のフィールドの詳細は \fBpasswd\fP(5) を参照のこと。 .SH 返り値 \fBgetpwent\fP() 関数は \fIpasswd\fP 構造体へのポインターを返す。 これ以上エントリーが無いか、エラーが発生した場合は NULL を返す。 エラーが発生すると、 \fIerrno\fP が適切に設定される。 この関数の呼び出し後に \fIerrno\fP をチェックしたい場合は、呼び出し前に \fIerrno\fP を 0 に設定しておかないといけない。 .PP 返り値は静的な領域を指しており、その後の \fBgetpwent\fP(), \fBgetpwnam\fP(3), \fBgetpwuid\fP(3) の呼び出しで上書きされるかもしれない。 (返されたポインターを \fBfree\fP(3) に渡さないこと。) .SH エラー .TP \fBEINTR\fP シグナルが捕捉された。\fBsignal\fP(7) 参照。 .TP \fBEIO\fP I/O エラー。 .TP \fBEMFILE\fP オープンされたファイルディスクリプター数がプロセス毎の上限に達している。 .TP \fBENFILE\fP オープンされたファイルの総数がシステム全体の上限に達している。 .TP \fBENOMEM\fP .\" not in POSIX .\" to allocate the passwd structure, or to allocate buffers \fIpasswd\fP 構造体に割り当てるメモリーが十分なかった。 .TP \fBERANGE\fP 与えられたバッファー空間が不十分である。 .SH ファイル .TP \fI/etc/passwd\fP ローカルのパスワードデータベースファイル .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lbw11 lb lb l l l. インターフェース 属性 値 T{ \fBgetpwent\fP() T} Thread safety T{ MT\-Unsafe race:pwent .br race:pwentbuf locale T} T{ \fBsetpwent\fP(), .br \fBendpwent\fP() T} Thread safety MT\-Unsafe race:pwent locale .TE .sp 1 In the above table, \fIpwent\fP in \fIrace:pwent\fP signifies that if any of the functions \fBsetpwent\fP(), \fBgetpwent\fP(), or \fBendpwent\fP() are used in parallel in different threads of a program, then data races could occur. .SH 準拠 POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.3BSD. \fIpw_gecos\fP フィールドは POSIX では規定されていないが、 ほとんどの実装に存在する。 .SH 関連項目 \fBfgetpwent\fP(3), \fBgetpw\fP(3), \fBgetpwent_r\fP(3), \fBgetpwnam\fP(3), \fBgetpwuid\fP(3), \fBputpwent\fP(3), \fBpasswd\fP(5) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。