]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/getpw.3
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man3 / getpw.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .\" References consulted:
6 .\" Linux libc source code
7 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
8 .\" 386BSD man pages
9 .\" Modified Sat Jul 24 19:23:25 1993 by Rik Faith (faith@cs.unc.edu)
10 .\" Modified Mon May 27 21:37:47 1996 by Martin Schulze (joey@linux.de)
11 .\"
12 .TH getpw 3 (date) "Linux man-pages (unreleased)"
13 .SH NAME
14 getpw \- reconstruct password line entry
15 .SH LIBRARY
16 Standard C library
17 .RI ( libc ", " \-lc )
18 .SH SYNOPSIS
19 .nf
20 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
21 .B #include <sys/types.h>
22 .B #include <pwd.h>
23 .PP
24 .BI "[[deprecated]] int getpw(uid_t " uid ", char *" buf );
25 .fi
26 .SH DESCRIPTION
27 The
28 .BR getpw ()
29 function reconstructs the password line entry for
30 the given user ID \fIuid\fP in the buffer \fIbuf\fP.
31 The returned buffer contains a line of format
32 .PP
33 .in +4n
34 .EX
35 .B name:passwd:uid:gid:gecos:dir:shell
36 .EE
37 .in
38 .PP
39 The \fIpasswd\fP structure is defined in \fI<pwd.h>\fP as follows:
40 .PP
41 .in +4n
42 .EX
43 struct passwd {
44 char *pw_name; /* username */
45 char *pw_passwd; /* user password */
46 uid_t pw_uid; /* user ID */
47 gid_t pw_gid; /* group ID */
48 char *pw_gecos; /* user information */
49 char *pw_dir; /* home directory */
50 char *pw_shell; /* shell program */
51 };
52 .EE
53 .in
54 .PP
55 For more information about the fields of this structure, see
56 .BR passwd (5).
57 .SH RETURN VALUE
58 The
59 .BR getpw ()
60 function returns 0 on success; on error, it returns \-1, and
61 .I errno
62 is set to indicate the error.
63 .PP
64 If
65 .I uid
66 is not found in the password database,
67 .BR getpw ()
68 returns \-1, sets
69 .I errno
70 to 0, and leaves
71 .I buf
72 unchanged.
73 .SH ERRORS
74 .TP
75 .BR 0 " or " ENOENT
76 No user corresponding to
77 .IR uid .
78 .TP
79 .B EINVAL
80 .I buf
81 is NULL.
82 .TP
83 .B ENOMEM
84 Insufficient memory to allocate
85 .I passwd
86 structure.
87 .SH FILES
88 .TP
89 .I /etc/passwd
90 password database file
91 .SH ATTRIBUTES
92 For an explanation of the terms used in this section, see
93 .BR attributes (7).
94 .ad l
95 .nh
96 .TS
97 allbox;
98 lbx lb lb
99 l l l.
100 Interface Attribute Value
101 T{
102 .BR getpw ()
103 T} Thread safety MT-Safe locale
104 .TE
105 .hy
106 .ad
107 .sp 1
108 .SH STANDARDS
109 SVr2.
110 .SH BUGS
111 The
112 .BR getpw ()
113 function is dangerous as it may overflow the provided buffer
114 .IR buf .
115 It is obsoleted by
116 .BR getpwuid (3).
117 .SH SEE ALSO
118 .BR endpwent (3),
119 .BR fgetpwent (3),
120 .BR getpwent (3),
121 .BR getpwnam (3),
122 .BR getpwuid (3),
123 .BR putpwent (3),
124 .BR setpwent (3),
125 .BR passwd (5)