1getpw(3)                   Library Functions Manual                   getpw(3)
2
3
4

NAME

6       getpw - reconstruct password line entry
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #define _GNU_SOURCE             /* See feature_test_macros(7) */
13       #include <sys/types.h>
14       #include <pwd.h>
15
16       [[deprecated]] int getpw(uid_t uid, char *buf);
17

DESCRIPTION

19       The getpw() function reconstructs the password line entry for the given
20       user ID uid in the buffer buf.  The returned buffer contains a line  of
21       format
22
23           name:passwd:uid:gid:gecos:dir:shell
24
25       The passwd structure is defined in <pwd.h> as follows:
26
27           struct passwd {
28               char   *pw_name;       /* username */
29               char   *pw_passwd;     /* user password */
30               uid_t   pw_uid;        /* user ID */
31               gid_t   pw_gid;        /* group ID */
32               char   *pw_gecos;      /* user information */
33               char   *pw_dir;        /* home directory */
34               char   *pw_shell;      /* shell program */
35           };
36
37       For more information about the fields of this structure, see passwd(5).
38

RETURN VALUE

40       The getpw() function returns 0 on success; on error, it returns -1, and
41       errno is set to indicate the error.
42
43       If uid is not found in the password database, getpw() returns -1,  sets
44       errno to 0, and leaves buf unchanged.
45

ERRORS

47       0 or ENOENT
48              No user corresponding to uid.
49
50       EINVAL buf is NULL.
51
52       ENOMEM Insufficient memory to allocate passwd structure.
53

FILES

55       /etc/passwd
56              password database file
57

ATTRIBUTES

59       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
60       tributes(7).
61
62       ┌─────────────────────────────────────┬───────────────┬────────────────┐
63Interface                            Attribute     Value          
64       ├─────────────────────────────────────┼───────────────┼────────────────┤
65getpw()                              │ Thread safety │ MT-Safe locale │
66       └─────────────────────────────────────┴───────────────┴────────────────┘
67

STANDARDS

69       None.
70

HISTORY

72       SVr2.
73

BUGS

75       The getpw() function is dangerous  as  it  may  overflow  the  provided
76       buffer buf.  It is obsoleted by getpwuid(3).
77

SEE ALSO

79       endpwent(3),   fgetpwent(3),   getpwent(3),  getpwnam(3),  getpwuid(3),
80       putpwent(3), setpwent(3), passwd(5)
81
82
83
84Linux man-pages 6.05              2023-07-20                          getpw(3)
Impressum