]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/getpwent.3
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man3 / getpwent.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\" 386BSD man pages
27 .\"
28 .\" Modified Sat Jul 24 19:22:14 1993 by Rik Faith (faith@cs.unc.edu)
29 .\" Modified Mon May 27 21:37:47 1996 by Martin Schulze (joey@linux.de)
30 .\"
31 .TH GETPWENT 3 1996-05-27 "GNU" "Linux Programmer's Manual"
32 .SH NAME
33 getpwent, setpwent, endpwent \- get password file entry
34 .SH SYNOPSIS
35 .nf
36 .B #include <sys/types.h>
37 .B #include <pwd.h>
38 .sp
39 .B struct passwd *getpwent(void);
40 .sp
41 .B void setpwent(void);
42 .sp
43 .B void endpwent(void);
44 .fi
45 .SH DESCRIPTION
46 The \fBgetpwent\fP() function returns a pointer to a structure containing
47 the broken-out fields of a record from the password database
48 (e.g., the local password file
49 .IR /etc/passwd ,
50 NIS, and LDAP).
51 The first time it
52 is called it returns the first entry; thereafter, it returns successive
53 entries.
54 .PP
55 The \fBsetpwent\fP() function rewinds to the beginning
56 of the password database.
57 .PP
58 The \fBendpwent\fP() function is used to close the password database
59 after all processing has been performed.
60 .PP
61 The \fIpasswd\fP structure is defined in \fI<pwd.h>\fP as follows:
62 .sp
63 .RS 0.25i
64 .nf
65 struct passwd {
66 char *pw_name; /* user name */
67 char *pw_passwd; /* user password */
68 uid_t pw_uid; /* user ID */
69 gid_t pw_gid; /* group ID */
70 char *pw_gecos; /* real name */
71 char *pw_dir; /* home directory */
72 char *pw_shell; /* shell program */
73 };
74 .fi
75 .RE
76 .SH "RETURN VALUE"
77 The \fBgetpwent\fP() function returns a pointer to a
78 .I passwd
79 structure, or NULL if
80 there are no more entries or an error occurs.
81 If an error occurs,
82 .I errno
83 is set appropriately.
84 If one wants to check
85 .I errno
86 after the call, it should be set to zero before the call.
87 .SH ERRORS
88 .TP
89 .B EINTR
90 A signal was caught.
91 .TP
92 .B EIO
93 I/O error.
94 .TP
95 .B EMFILE
96 The maximum number (OPEN_MAX) of files was open already in the calling process.
97 .TP
98 .B ENFILE
99 The maximum number of files was open already in the system.
100 .TP
101 .B ENOMEM
102 .\" not in POSIX
103 Insufficient memory to allocate passwd structure.
104 .\" to allocate the passwd structure, or to allocate buffers
105 .TP
106 .B ERANGE
107 Insufficient buffer space supplied.
108 .SH FILES
109 .TP
110 .I /etc/passwd
111 local password database file
112 .SH "CONFORMING TO"
113 SVr4, 4.3BSD, POSIX.1-2001.
114 .SH "SEE ALSO"
115 .BR fgetpwent (3),
116 .BR getpw (3),
117 .BR getpwent_r (3),
118 .BR getpwnam (3),
119 .BR getpwuid (3),
120 .BR putpwent (3),
121 .BR passwd (5)