2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" References consulted:
7 .\" Linux libc source code
8 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
10 .\" Modified Sat Jul 24 19:23:25 1993 by Rik Faith (faith@cs.unc.edu)
11 .\" Modified Mon May 27 21:37:47 1996 by Martin Schulze (joey@linux.de)
13 .TH getpw 3 (date) "Linux man-pages (unreleased)"
15 getpw \- reconstruct password line entry
18 .RI ( libc ", " \-lc )
21 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
22 .B #include <sys/types.h>
25 .BI "[[deprecated]] int getpw(uid_t " uid ", char *" buf );
30 function reconstructs the password line entry for
31 the given user ID \fIuid\fP in the buffer \fIbuf\fP.
32 The returned buffer contains a line of format
36 .B name:passwd:uid:gid:gecos:dir:shell
40 The \fIpasswd\fP structure is defined in \fI<pwd.h>\fP as follows:
45 char *pw_name; /* username */
46 char *pw_passwd; /* user password */
47 uid_t pw_uid; /* user ID */
48 gid_t pw_gid; /* group ID */
49 char *pw_gecos; /* user information */
50 char *pw_dir; /* home directory */
51 char *pw_shell; /* shell program */
56 For more information about the fields of this structure, see
61 function returns 0 on success; on error, it returns \-1, and
63 is set to indicate the error.
67 is not found in the password database,
77 No user corresponding to
85 Insufficient memory to allocate
91 password database file
93 For an explanation of the terms used in this section, see
101 Interface Attribute Value
104 T} Thread safety MT-Safe locale
114 function is dangerous as it may overflow the provided buffer