OSDN Git Service

e6ad94d410304f60971149f6470a5c7828341ee7
[linuxjm/LDP_man-pages.git] / original / man3 / getpw.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
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.
7 .\"
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.
12 .\"
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
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
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)
31 .\"
32 .TH GETPW 3 2010-10-21 "GNU" "Linux Programmer's Manual"
33 .SH NAME
34 getpw \- reconstruct password line entry
35 .SH SYNOPSIS
36 .nf
37 .BR "#define _GNU_SOURCE" "             /* See feature_test_macros(7) */"
38 .B #include <sys/types.h>
39 .B #include <pwd.h>
40 .sp
41 .BI "int getpw(uid_t " uid ", char *" buf );
42 .fi
43 .SH DESCRIPTION
44 The
45 .BR getpw ()
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
49 .sp
50 .RS
51 .B name:passwd:uid:gid:gecos:dir:shell
52 .RE
53 .PP
54 The \fIpasswd\fP structure is defined in \fI<pwd.h>\fP as follows:
55 .sp
56 .in +4n
57 .nf
58 struct passwd {
59     char   *pw_name;       /* username */
60     char   *pw_passwd;     /* user password */
61     uid_t   pw_uid;        /* user ID */
62     gid_t   pw_gid;        /* group ID */
63     char   *pw_gecos;      /* user information */
64     char   *pw_dir;        /* home directory */
65     char   *pw_shell;      /* shell program */
66 };
67 .fi
68 .in
69 .PP
70 For more information about the fields of this structure, see
71 .BR passwd (5).
72 .SH RETURN VALUE
73 The
74 .BR getpw ()
75 function returns 0 on success; on error, it returns \-1, and
76 .I errno
77 is set to indicate the error.
78 .SH ERRORS
79 .TP
80 .B EINVAL
81 .I buf
82 is NULL.
83 .TP
84 .B ENOENT
85 No user corresponding to
86 .IR uid .
87 .TP
88 .B ENOMEM
89 Insufficient memory to allocate
90 .I passwd
91 structure.
92 .SH FILES
93 .TP
94 .I /etc/passwd
95 password database file
96 .SH CONFORMING TO
97 SVr2.
98 .SH BUGS
99 The
100 .BR getpw ()
101 function is dangerous as it may overflow the provided buffer
102 .IR buf .
103 It is obsoleted by
104 .BR getpwuid (3).
105 .SH SEE ALSO
106 .BR endpwent (3),
107 .BR fgetpwent (3),
108 .BR getpwent (3),
109 .BR getpwnam (3),
110 .BR getpwuid (3),
111 .BR putpwent (3),
112 .BR setpwent (3),
113 .BR passwd (5)
114 .SH COLOPHON
115 This page is part of release 3.64 of the Linux
116 .I man-pages
117 project.
118 A description of the project,
119 and information about reporting bugs,
120 can be found at
121 \%http://www.kernel.org/doc/man\-pages/.