1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" %%%LICENSE_START(VERBATIM)
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.
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.
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
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" References consulted:
26 .\" Linux libc source code
27 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
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)
32 .TH GETPW 3 2021-03-22 "GNU" "Linux Programmer's Manual"
34 getpw \- reconstruct password line entry
37 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
38 .B #include <sys/types.h>
41 .BI "int getpw(uid_t " uid ", char *" buf );
46 function reconstructs the password line entry for
47 the given user ID \fIuid\fP in the buffer \fIbuf\fP.
48 The returned buffer contains a line of format
52 .B name:passwd:uid:gid:gecos:dir:shell
56 The \fIpasswd\fP structure is defined in \fI<pwd.h>\fP as follows:
61 char *pw_name; /* username */
62 char *pw_passwd; /* user password */
63 uid_t pw_uid; /* user ID */
64 gid_t pw_gid; /* group ID */
65 char *pw_gecos; /* user information */
66 char *pw_dir; /* home directory */
67 char *pw_shell; /* shell program */
72 For more information about the fields of this structure, see
77 function returns 0 on success; on error, it returns \-1, and
79 is set to indicate the error.
83 is not found in the password database,
93 No user corresponding to
101 Insufficient memory to allocate
107 password database file
109 For an explanation of the terms used in this section, see
117 Interface Attribute Value
120 T} Thread safety MT-Safe locale
130 function is dangerous as it may overflow the provided buffer