1GETPW(3)                   Linux Programmer's Manual                  GETPW(3)
2
3
4

NAME

6       getpw - reconstruct password line entry
7

SYNOPSIS

9       #define _GNU_SOURCE             /* See feature_test_macros(7) */
10       #include <sys/types.h>
11       #include <pwd.h>
12
13       int getpw(uid_t uid, char *buf);
14

DESCRIPTION

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;      /* user information */
30               char   *pw_dir;        /* home directory */
31               char   *pw_shell;      /* shell program */
32           };
33
34       For more information about the fields of this structure, see passwd(5).
35

RETURN VALUE

37       The getpw() function returns 0 on success; on error, it returns -1, and
38       errno is set to indicate the error.
39

ERRORS

41       EINVAL buf is NULL.
42
43       ENOENT No user corresponding to uid.
44
45       ENOMEM Insufficient memory to allocate passwd structure.
46

FILES

48       /etc/passwd
49              password database file
50

CONFORMING TO

52       SVr2.
53

BUGS

55       The getpw() function is dangerous as it may overflow the provided  buf‐
56       fer buf.  It is obsoleted by getpwuid(3).
57

SEE ALSO

59       endpwent(3), fgetpwent(3), getpwent(3), getpwnam(3), getpwuid(3), putp‐
60       went(3), setpwent(3), passwd(5)
61

COLOPHON

63       This page is part of release 3.53 of the Linux  man-pages  project.   A
64       description  of  the project, and information about reporting bugs, can
65       be found at http://www.kernel.org/doc/man-pages/.
66
67
68
69GNU                               2010-10-21                          GETPW(3)
Impressum