File: getpwent.3

package info (click to toggle)
manpages-ja 0.5.0.0.20210215%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 28,568 kB
  • sloc: perl: 161; makefile: 58
file content (141 lines) | stat: -rw-r--r-- 6,002 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
.\" 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 <nishi@rpts.cl.nec.co.jp>
.\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\"
.TH GETPWENT 3 2013\-06\-21 GNU "Linux Programmer's Manual"
.SH 名前
getpwent, setpwent, endpwent \- パスワードファイルのエントリーの取得
.SH 書式
.nf
\fB#include <sys/types.h>\fP
\fB#include <pwd.h>\fP
.sp
\fBstruct passwd *getpwent(void);\fP
.sp
\fBvoid setpwent(void);\fP
.sp
\fBvoid endpwent(void);\fP
.fi
.sp
.in -4n
glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
.in
.sp
.ad l
\fBgetpwent\fP(), \fBsetpwent\fP(), \fBendpwent\fP():
.RS 4
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
.RE
.ad b
.SH 説明
\fBgetpwent\fP()  関数は、パスワードデータベースから取得したエントリーを 要素毎に分解し、各要素を格納した構造体へのポインターを返す
(パスワードデータベースの例: ローカルのパスワードファイル \fI/etc/passwd\fP, NIS, LDAP)。 \fBgetpwent\fP()
は、最初に呼び出された時は最初のエントリーを返し、それ以降は 呼び出される毎に次のエントリーを返す。
.PP
\fBsetpwent\fP()  関数を使うと、パスワードデータベースの先頭に戻る。
.PP
\fBendpwent\fP()  関数は、全ての処理が終わった後にパスワード データベースをクローズする。
.PP
\fIpasswd\fP 構造体は、\fI<pwd.h>\fP で以下のように定義されている:
.sp
.in +4n
.nf
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;      /* シェルプログラム */
};
.fi
.in
.PP
この構造体のフィールドの詳細は \fBpasswd\fP(5)  を参照のこと。
.SH 返り値
\fBgetpwent\fP()  関数は \fIpasswd\fP 構造体へのポインターを返す。 これ以上エントリーが無いか、エラーが発生した場合は NULL
を返す。 エラーが発生すると、 \fIerrno\fP が適切に設定される。 この関数の呼び出し後に \fIerrno\fP をチェックしたい場合は、呼び出し前に
\fIerrno\fP を 0 に設定しておかないといけない。

返り値は静的な領域を指しており、その後の \fBgetpwent\fP(), \fBgetpwnam\fP(3), \fBgetpwuid\fP(3)
の呼び出しで上書きされるかもしれない。 (返されたポインターを \fBfree\fP(3)  に渡さないこと。)
.SH エラー
.TP 
\fBEINTR\fP
シグナルが捕捉された。
.TP 
\fBEIO\fP
I/O エラー。
.TP 
\fBEMFILE\fP
呼び出し元プロセスがオープンしているファイル数が すでに上限 (\fBOPEN_MAX\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 属性
.SS "マルチスレッディング (pthreads(7) 参照)"
\fBgetpwent\fP() 関数はスレッドセーフではない。
.LP
関数 \fBsetpwent\fP() と \fBendpwent\fP() はスレッドセーフである。
.SH 準拠
SVr4, 4.3BSD, POSIX.1\-2001.  \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 プロジェクトのリリース 3.79 の一部
である。プロジェクトの説明とバグ報告に関する情報は
http://www.kernel.org/doc/man\-pages/ に書かれている。