Commit | Line | Data |
---|---|---|
62ab31a2 KB |
1 | .\" Copyright (c) 1988 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
5 | .\" @(#)getpwent.3 6.4 (Berkeley) %G% | |
4e6e003a | 6 | .\" |
3fb9eae6 | 7 | .TH GETPWENT 3 "" |
4e6e003a KM |
8 | .AT 3 |
9 | .SH NAME | |
3fb9eae6 | 10 | getpwent, getpwuid, getpwnam, setpwent, endpwent, setpwfile \- get password file entry |
4e6e003a KM |
11 | .SH SYNOPSIS |
12 | .nf | |
13 | .B #include <pwd.h> | |
14 | .PP | |
4e6e003a | 15 | .B struct passwd *getpwuid(uid) |
62ab31a2 | 16 | .B uid_t uid; |
4e6e003a KM |
17 | .PP |
18 | .B struct passwd *getpwnam(name) | |
19 | .B char *name; | |
20 | .PP | |
1e00f4a7 KM |
21 | .B struct passwd *getpwent() |
22 | .PP | |
62ab31a2 | 23 | .B void setpwent() |
4e6e003a | 24 | .PP |
62ab31a2 | 25 | .B void endpwent() |
3fb9eae6 KM |
26 | .PP |
27 | .B setpwfile(name) | |
28 | .B char *name; | |
4e6e003a KM |
29 | .fi |
30 | .SH DESCRIPTION | |
31 | .I Getpwent, | |
32 | .I getpwuid | |
33 | and | |
34 | .I getpwnam | |
62ab31a2 KB |
35 | each return a pointer to an object with the following structure, |
36 | containing the broken-out fields of a line in the password file, | |
37 | as described in | |
38 | .IR < pwd.h > . | |
4e6e003a KM |
39 | .RS |
40 | .PP | |
41 | .nf | |
62ab31a2 KB |
42 | struct passwd { |
43 | char *pw_name; | |
44 | char *pw_passwd; | |
45 | uid_t pw_uid; | |
46 | gid_t pw_gid; | |
47 | int pw_quota; | |
48 | char *pw_comment; | |
49 | char *pw_gecos; | |
50 | char *pw_dir; | |
51 | char *pw_shell; | |
52 | }; | |
4e6e003a KM |
53 | .ft R |
54 | .ad | |
55 | .fi | |
56 | .RE | |
57 | .PP | |
58 | The fields | |
59 | .I pw_quota | |
60 | and | |
61 | .I pw_comment | |
62 | are unused; the others have meanings described in | |
63 | .IR passwd (5). | |
64 | .PP | |
62ab31a2 KB |
65 | .I Setpwfile |
66 | changes the default password file to | |
67 | .IR name , | |
68 | thus allowing usage of alternate password files. If \fIndbm\fP databases | |
69 | are available for any password files, they are used, otherwise the file | |
70 | itself is linearly searched. | |
71 | .PP | |
1e00f4a7 | 72 | .I Setpwent |
62ab31a2 KB |
73 | opens the database or file (closing any previously opened database or file) |
74 | or rewinds it if it is already open. | |
75 | .PP | |
76 | .I Endpwent | |
77 | closes any open databases or files. | |
78 | .PP | |
1e00f4a7 KM |
79 | .I Getpwuid |
80 | and | |
81 | .I getpwnam | |
62ab31a2 | 82 | search the entire database or file (opening it if necessary) for a matching |
1e00f4a7 KM |
83 | .I uid |
84 | or | |
85 | .IR name . | |
1e00f4a7 KM |
86 | .PP |
87 | For programs wishing to read the entire database, | |
88 | .I getpwent | |
62ab31a2 | 89 | reads the next entry (opening the database or file if necessary). |
4e6e003a KM |
90 | .SH FILES |
91 | /etc/passwd | |
92 | .SH "SEE ALSO" | |
93 | getlogin(3), getgrent(3), passwd(5) | |
94 | .SH DIAGNOSTICS | |
c5892565 KM |
95 | The routines |
96 | .IR getpwent , | |
97 | .IR getpwuid , | |
98 | and | |
99 | .IR getpwnam , | |
100 | return a null pointer (0) on EOF or error. | |
62ab31a2 KB |
101 | .I Setpwent |
102 | returns 0 on failure, 1 on success. | |
103 | .I Endpwent | |
104 | and | |
105 | .I setpwfile | |
106 | have no return value. | |
4e6e003a | 107 | .SH BUGS |
62ab31a2 KB |
108 | All information is contained in a static area so it must be |
109 | copied if it is to be saved. |