1GETPW(3) Linux Programmer's Manual GETPW(3)
2
3
4
6 getpw - Re-construct password line entry
7
9 #define _GNU_SOURCE
10 #include <sys/types.h>
11 #include <pwd.h>
12
13 int getpw(uid_t uid, char *buf);
14
16 The getpw() function reconstructs the password line entry for the given
17 user ID uid in the buffer buf. The returned buffer contains a line of
18 format
19
20 name:passwd:uid:gid:gecos:dir:shell
21
22 The passwd structure is defined in <pwd.h> as follows:
23
24 struct passwd {
25 char *pw_name; /* username */
26 char *pw_passwd; /* user password */
27 uid_t pw_uid; /* user ID */
28 gid_t pw_gid; /* group ID */
29 char *pw_gecos; /* real name */
30 char *pw_dir; /* home directory */
31 char *pw_shell; /* shell program */
32 };
33
35 The getpw() function returns 0 on success; on error, it returns -1, and
36 errno is set to indicate the error.
37
39 EINVAL buf is NULL.
40
41 ENOENT No user corresponding to uid.
42
43 ENOMEM Insufficient memory to allocate passwd structure.
44
46 /etc/passwd
47 password database file
48
50 SVr2.
51
53 The getpw() function is dangerous as it may overflow the provided buf‐
54 fer buf. It is obsoleted by getpwuid(3).
55
57 endpwent(3), fgetpwent(3), getpwent(3), getpwnam(3), getpwuid(3), putp‐
58 went(3), setpwent(3), passwd(5)
59
61 This page is part of release 3.25 of the Linux man-pages project. A
62 description of the project, and information about reporting bugs, can
63 be found at http://www.kernel.org/doc/man-pages/.
64
65
66
67GNU 2007-12-12 GETPW(3)