]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da MK |
24 | .\" |
25 | .\" References consulted: | |
26 | .\" Linux libc source code | |
27 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
28 | .\" 386BSD man pages | |
29 | .\" Modified Sat Jul 24 19:23:25 1993 by Rik Faith (faith@cs.unc.edu) | |
30 | .\" Modified Mon May 27 21:37:47 1996 by Martin Schulze (joey@linux.de) | |
31 | .\" | |
4b8c67d9 | 32 | .TH GETPW 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
fea681da | 33 | .SH NAME |
f68512e9 | 34 | getpw \- reconstruct password line entry |
fea681da MK |
35 | .SH SYNOPSIS |
36 | .nf | |
86b91fdf | 37 | .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" |
fea681da MK |
38 | .B #include <sys/types.h> |
39 | .B #include <pwd.h> | |
68e4db0a | 40 | .PP |
fea681da MK |
41 | .BI "int getpw(uid_t " uid ", char *" buf ); |
42 | .fi | |
43 | .SH DESCRIPTION | |
60a90ecd MK |
44 | The |
45 | .BR getpw () | |
3b777aff | 46 | function reconstructs the password line entry for |
1c44bd5b MK |
47 | the given user ID \fIuid\fP in the buffer \fIbuf\fP. |
48 | The returned buffer contains a line of format | |
bdd915e2 MK |
49 | .PP |
50 | .in +4n | |
b9c93deb | 51 | .EX |
fea681da | 52 | .B name:passwd:uid:gid:gecos:dir:shell |
bdd915e2 MK |
53 | .EE |
54 | .in | |
fea681da MK |
55 | .PP |
56 | The \fIpasswd\fP structure is defined in \fI<pwd.h>\fP as follows: | |
51f5698d | 57 | .PP |
bd191423 | 58 | .in +4n |
b8302363 | 59 | .EX |
fea681da | 60 | struct passwd { |
18701562 | 61 | char *pw_name; /* username */ |
7295b7ed MK |
62 | char *pw_passwd; /* user password */ |
63 | uid_t pw_uid; /* user ID */ | |
64 | gid_t pw_gid; /* group ID */ | |
59f65cfd | 65 | char *pw_gecos; /* user information */ |
7295b7ed MK |
66 | char *pw_dir; /* home directory */ |
67 | char *pw_shell; /* shell program */ | |
fea681da | 68 | }; |
b8302363 | 69 | .EE |
bd191423 | 70 | .in |
7f12f117 MK |
71 | .PP |
72 | For more information about the fields of this structure, see | |
73 | .BR passwd (5). | |
47297adb | 74 | .SH RETURN VALUE |
60a90ecd MK |
75 | The |
76 | .BR getpw () | |
a7e4a8f2 MK |
77 | function returns 0 on success; on error, it returns \-1, and |
78 | .I errno | |
79 | is set to indicate the error. | |
847e0d88 | 80 | .PP |
44517b7b MK |
81 | If |
82 | .I uid | |
83 | is not found in the password database, | |
84 | .BR getpw () | |
8a11899c | 85 | returns \-1, sets |
44517b7b MK |
86 | .I errno |
87 | to 0, and leaves | |
88 | .I buf | |
89 | unchanged. | |
fea681da MK |
90 | .SH ERRORS |
91 | .TP | |
44517b7b MK |
92 | .BR 0 " or " ENOENT |
93 | No user corresponding to | |
94 | .IR uid . | |
95 | .TP | |
a7e4a8f2 MK |
96 | .B EINVAL |
97 | .I buf | |
98 | is NULL. | |
99 | .TP | |
fea681da | 100 | .B ENOMEM |
a7e4a8f2 MK |
101 | Insufficient memory to allocate |
102 | .I passwd | |
103 | structure. | |
fea681da MK |
104 | .SH FILES |
105 | .TP | |
106 | .I /etc/passwd | |
107 | password database file | |
91a7c375 ZL |
108 | .SH ATTRIBUTES |
109 | For an explanation of the terms used in this section, see | |
110 | .BR attributes (7). | |
111 | .TS | |
112 | allbox; | |
113 | lb lb lb | |
114 | l l l. | |
115 | Interface Attribute Value | |
116 | T{ | |
117 | .BR getpw () | |
118 | T} Thread safety MT-Safe locale | |
119 | .TE | |
847e0d88 | 120 | .sp 1 |
47297adb | 121 | .SH CONFORMING TO |
80b50848 | 122 | SVr2. |
fea681da MK |
123 | .SH BUGS |
124 | The | |
125 | .BR getpw () | |
126 | function is dangerous as it may overflow the provided buffer | |
127 | .IR buf . | |
c13182ef | 128 | It is obsoleted by |
fb186734 | 129 | .BR getpwuid (3). |
47297adb | 130 | .SH SEE ALSO |
fea681da MK |
131 | .BR endpwent (3), |
132 | .BR fgetpwent (3), | |
133 | .BR getpwent (3), | |
134 | .BR getpwnam (3), | |
135 | .BR getpwuid (3), | |
136 | .BR putpwent (3), | |
137 | .BR setpwent (3), | |
138 | .BR passwd (5) |