Commit | Line | Data |
---|---|---|
1e00f4a7 | 1 | .\" @(#)getpwent.3 6.3 (Berkeley) %G% |
4e6e003a | 2 | .\" |
3fb9eae6 | 3 | .TH GETPWENT 3 "" |
4e6e003a KM |
4 | .AT 3 |
5 | .SH NAME | |
3fb9eae6 | 6 | getpwent, getpwuid, getpwnam, setpwent, endpwent, setpwfile \- get password file entry |
4e6e003a KM |
7 | .SH SYNOPSIS |
8 | .nf | |
9 | .B #include <pwd.h> | |
10 | .PP | |
4e6e003a KM |
11 | .B struct passwd *getpwuid(uid) |
12 | .B int uid; | |
13 | .PP | |
14 | .B struct passwd *getpwnam(name) | |
15 | .B char *name; | |
16 | .PP | |
1e00f4a7 KM |
17 | .B struct passwd *getpwent() |
18 | .PP | |
c5892565 | 19 | .B setpwent() |
4e6e003a | 20 | .PP |
c5892565 | 21 | .B endpwent() |
3fb9eae6 KM |
22 | .PP |
23 | .B setpwfile(name) | |
24 | .B char *name; | |
4e6e003a KM |
25 | .fi |
26 | .SH DESCRIPTION | |
27 | .I Getpwent, | |
28 | .I getpwuid | |
29 | and | |
30 | .I getpwnam | |
31 | each return a pointer to an object with the | |
32 | following structure | |
33 | containing the broken-out | |
34 | fields of a line in the password file. | |
35 | .RS | |
36 | .PP | |
37 | .nf | |
38 | .so /usr/include/pwd.h | |
39 | .ft R | |
40 | .ad | |
41 | .fi | |
42 | .RE | |
43 | .PP | |
44 | The fields | |
45 | .I pw_quota | |
46 | and | |
47 | .I pw_comment | |
48 | are unused; the others have meanings described in | |
49 | .IR passwd (5). | |
50 | .PP | |
1e00f4a7 KM |
51 | Searching of the password file is done using the \fIndbm\fP |
52 | database access routines. | |
53 | .I Setpwent | |
54 | opens the database; | |
4e6e003a KM |
55 | .I endpwent |
56 | closes it. | |
1e00f4a7 KM |
57 | .I Getpwuid |
58 | and | |
59 | .I getpwnam | |
60 | search the database (opening it if necessary) for a matching | |
61 | .I uid | |
62 | or | |
63 | .IR name . | |
64 | EOF is returned if there is no entry. | |
65 | .PP | |
66 | For programs wishing to read the entire database, | |
67 | .I getpwent | |
68 | reads the next | |
69 | line (opening the database if necessary). | |
70 | In addition to opening the database, | |
71 | .I setpwent | |
72 | can be used to make | |
73 | .I getpwent | |
74 | begin its search from the beginning of the database. | |
4e6e003a | 75 | .PP |
3fb9eae6 KM |
76 | .I Setpwfile |
77 | changes the default password file to | |
78 | .I name | |
79 | thus allowing alternate password files to be used. | |
80 | Note that it does | |
81 | .I not | |
82 | close the previous file. | |
83 | If this is desired, | |
84 | .I endpwent | |
85 | should be called prior to it. | |
4e6e003a KM |
86 | .SH FILES |
87 | /etc/passwd | |
88 | .SH "SEE ALSO" | |
89 | getlogin(3), getgrent(3), passwd(5) | |
90 | .SH DIAGNOSTICS | |
c5892565 KM |
91 | The routines |
92 | .IR getpwent , | |
93 | .IR getpwuid , | |
94 | and | |
95 | .IR getpwnam , | |
96 | return a null pointer (0) on EOF or error. | |
4e6e003a KM |
97 | .SH BUGS |
98 | All information | |
99 | is contained in a static area | |
100 | so it must be copied if it is | |
101 | to be saved. |