Debian Codegraph @

upstream/debian-unstable/man3/fgetpwent.3

raw
1 '\" t
2 .\" Copyright 1993, David Metcalfe <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH fgetpwent 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 fgetpwent \- get password file entry
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <stdio.h>
16 .B #include <sys/types.h>
17 .B #include <pwd.h>
18 .P
19 .BI "struct passwd *fgetpwent(FILE *" stream );
20 .fi
21 .P
22 .RS -4
23 Feature Test Macro Requirements for glibc (see
24 .BR feature_test_macros (7)):
25 .RE
26 .P
27 .BR fgetpwent ():
28 .nf
29 Since glibc 2.19:
30 _DEFAULT_SOURCE
31 glibc 2.19 and earlier:
32 _SVID_SOURCE
33 .fi
34 .SH DESCRIPTION
35 The
36 .BR fgetpwent ()
37 function returns a pointer to a structure containing
38 the broken out fields of a line in the file
39 .IR stream .
40 The first time it is called it returns the first entry;
41 thereafter, it returns successive entries.
42 The file referred to by
43 .I stream
44 must have the same format as
45 .I /etc/passwd
46 (see
47 .BR passwd (5)).
48 .P
49 The
50 .I passwd
51 structure is defined in
52 .I <pwd.h>
53 as follows:
54 .P
55 .in +4n
56 .EX
57 struct passwd {
58 char *pw_name; /* username */
59 char *pw_passwd; /* user password */
60 uid_t pw_uid; /* user ID */
61 gid_t pw_gid; /* group ID */
62 char *pw_gecos; /* real name */
63 char *pw_dir; /* home directory */
64 char *pw_shell; /* shell program */
65 };
66 .EE
67 .in
68 .SH RETURN VALUE
69 The
70 .BR fgetpwent ()
71 function returns a pointer to a
72 .I passwd
73 structure, or NULL if
74 there are no more entries or an error occurs.
75 In the event of an error,
76 .I errno
77 is set to indicate the error.
78 .SH ERRORS
79 .TP
80 .B ENOMEM
81 Insufficient memory to allocate
82 .I passwd
83 structure.
84 .SH FILES
85 .TP
86 .I /etc/passwd
87 password database file
88 .SH ATTRIBUTES
89 For an explanation of the terms used in this section, see
90 .BR attributes (7).
91 .TS
92 allbox;
93 lbx lb lb
94 l l l.
95 Interface Attribute Value
96 T{
97 .na
98 .nh
99 .BR fgetpwent ()
100 T} Thread safety MT-Unsafe race:fgetpwent
101 .TE
102 .\" FIXME: The marking is different from that in the glibc manual,
103 .\" which has:
104 .\"
105 .\" fgetpwent: MT-Unsafe race:fpwent
106 .\"
107 .\" We think race:fpwent in glibc maybe hard for users to understand,
108 .\" and have sent a patch to the GNU libc community for changing it to
109 .\" race:fgetpwent, however, something about the copyright impeded the
110 .\" progress.
111 .SH STANDARDS
112 None.
113 .SH HISTORY
114 SVr4.
115 .SH SEE ALSO
116 .BR endpwent (3),
117 .BR fgetpwent_r (3),
118 .BR fopen (3),
119 .BR getpw (3),
120 .BR getpwent (3),
121 .BR getpwnam (3),
122 .BR getpwuid (3),
123 .BR putpwent (3),
124 .BR setpwent (3),
125 .BR passwd (5)