3 getpwent, getpwnam, getpwuid, setpwent, endpwent, setpwfile \- password file routines
9 struct passwd *getpwent(void)
10 struct passwd *getpwnam(const char *\fIname\fP)
11 struct passwd *getpwuid(uid_t \fIuid\fP)
14 void setpwfile(const char *\fIfile\fP)
18 These functions are used to obtain information from the password file. They
19 return this information in a
21 as defined by <pwd.h>:
26 char *pw_name; /* login name */
27 char *pw_passwd; /* encrypted password */
28 uid_t pw_uid; /* numeric user id */
29 gid_t pw_gid; /* numeric group id */
30 char *pw_gecos; /* user full name and other info */
31 char *pw_dir; /* user's home directory */
32 char *pw_shell; /* name of the user's shell */
37 reads the password file entry by entry.
39 scans the entire password file for the user with the given
42 looks for the first user with the given
48 functions are used to open and later close the password file. With
50 one can specify the file to read other than the normal password file. This
51 only sets the name, the next
53 call will open the file. Do not touch the file name while it is active.
56 to revert back to the normal password file.
58 The usual way to scan the password file is (error checking omitted):
64 while ((pw = getpwent()) != NULL)
65 if (appropriate_test(pw)) break;
72 variable contains the entry that is wanted if non-NULL. The
76 functions are implemented as in this example, with error checking of course.
81 if this has not yet been done.
85 if the password file is still open. (Other implementations may simply
90 The password file database.
98 has the same return value and error codes as the
100 call it uses to open the password file. The
102 functions return NULL on end of file, entry not found, or error. You can
105 to zero before the call and check it after.
109 routines return a pointer to static storage that is overwritten in each call.
115 are defined by \s-2POSIX\s+2. The
117 macro must be defined before including <pwd.h> to make the other functions
122 fields are also not defined by \s-2POSIX\s+2, but are always visible.
123 Portable code cannot reliably detect errors by setting
125 to zero. Under MINIX 3 it is better to make a
127 scan if you need to look up several user-id's or names, but portable code
128 had better use several
134 is usually available on other systems, but may be very expensive.
136 Kees J. Bot (kjb@cs.vu.nl)
139 .\" $PchId: getpwent.3,v 1.2 1996/04/11 06:37:43 philip Exp $