2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
|
|
|
.\" References consulted:
|
|
|
|
.\" Linux libc source code
|
|
|
|
.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
|
|
|
|
.\" 386BSD man pages
|
|
|
|
.\" Modified Sat Jul 24 19:23:25 1993 by Rik Faith (faith@cs.unc.edu)
|
|
|
|
.\" Modified Mon May 27 21:37:47 1996 by Martin Schulze (joey@linux.de)
|
|
|
|
.\"
|
accept.2, clone.2, dup.2, fallocate.2, pipe.2, readahead.2, sched_setaffinity.2, unshare.2, CPU_SET.3, endian.3, euidaccess.3, fexecve.3, getpt.3, getpw.3, getumask.3, getutmp.3, gnu_get_libc_version.3, makedev.3, matherr.3, mbsnrtowcs.3, memfrob.3, pthread_attr_setaffinity_np.3, pthread_getattr_np.3, pthread_setaffinity_np.3, pthread_tryjoin_np.3, tcgetsid.3, wcscasecmp.3, wcsncasecmp.3, wcsnlen.3, wcsnrtombs.3, wcswidth.3, rtld-audit.7: SYNOPSIS: Add reference to feature_test_macros(7)
These pages specify feature test macros in the function
prototypes. Add a reference to feature_test_macros(7),
so that readers are pointed to the information that
feature test macros must be defined before including
*any* header file.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-10 05:06:22 +00:00
|
|
|
.TH GETPW 3 2010-09-10 "GNU" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
getpw \- Re-construct password line entry
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
accept.2, clone.2, dup.2, fallocate.2, pipe.2, readahead.2, sched_setaffinity.2, unshare.2, CPU_SET.3, endian.3, euidaccess.3, fexecve.3, getpt.3, getpw.3, getumask.3, getutmp.3, gnu_get_libc_version.3, makedev.3, matherr.3, mbsnrtowcs.3, memfrob.3, pthread_attr_setaffinity_np.3, pthread_getattr_np.3, pthread_setaffinity_np.3, pthread_tryjoin_np.3, tcgetsid.3, wcscasecmp.3, wcsncasecmp.3, wcsnlen.3, wcsnrtombs.3, wcswidth.3, rtld-audit.7: SYNOPSIS: Add reference to feature_test_macros(7)
These pages specify feature test macros in the function
prototypes. Add a reference to feature_test_macros(7),
so that readers are pointed to the information that
feature test macros must be defined before including
*any* header file.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-10 05:06:22 +00:00
|
|
|
.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
|
2004-11-03 13:51:07 +00:00
|
|
|
.B #include <sys/types.h>
|
|
|
|
.B #include <pwd.h>
|
|
|
|
.sp
|
|
|
|
.BI "int getpw(uid_t " uid ", char *" buf );
|
|
|
|
.fi
|
|
|
|
.SH DESCRIPTION
|
2007-05-12 09:06:04 +00:00
|
|
|
The
|
|
|
|
.BR getpw ()
|
close.2, epoll_create.2, epoll_ctl.2, fcntl.2, madvise.2, mmap.2, mremap.2, select_tut.2, setgid.2, setuid.2, syscalls.2, vmsplice.2, dlopen.3, fts.3, getpw.3, stdio.3, fd.4, initrd.4, random.4, sd.4, bootparam.7, capabilities.7, cpuset.7, epoll.7, inotify.7, man.7, socket.7, x25.7: Global fix: s/re-/re/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "re-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 17:45:23 +00:00
|
|
|
function reconstructs the password line entry for
|
2007-04-24 16:44:51 +00:00
|
|
|
the given user ID \fIuid\fP in the buffer \fIbuf\fP.
|
|
|
|
The returned buffer contains a line of format
|
2004-11-03 13:51:07 +00:00
|
|
|
.sp
|
|
|
|
.RS
|
|
|
|
.B name:passwd:uid:gid:gecos:dir:shell
|
|
|
|
.RE
|
|
|
|
.PP
|
|
|
|
The \fIpasswd\fP structure is defined in \fI<pwd.h>\fP as follows:
|
|
|
|
.sp
|
2007-12-19 06:16:04 +00:00
|
|
|
.in +4n
|
2004-11-03 13:51:07 +00:00
|
|
|
.nf
|
|
|
|
struct passwd {
|
2008-06-30 14:36:59 +00:00
|
|
|
char *pw_name; /* username */
|
2007-04-05 13:29:41 +00:00
|
|
|
char *pw_passwd; /* user password */
|
|
|
|
uid_t pw_uid; /* user ID */
|
|
|
|
gid_t pw_gid; /* group ID */
|
|
|
|
char *pw_gecos; /* real name */
|
|
|
|
char *pw_dir; /* home directory */
|
|
|
|
char *pw_shell; /* shell program */
|
2004-11-03 13:51:07 +00:00
|
|
|
};
|
|
|
|
.fi
|
2007-12-19 06:16:04 +00:00
|
|
|
.in
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "RETURN VALUE"
|
2007-05-12 09:06:04 +00:00
|
|
|
The
|
|
|
|
.BR getpw ()
|
2008-07-10 14:54:14 +00:00
|
|
|
function returns 0 on success; on error, it returns \-1, and
|
|
|
|
.I errno
|
|
|
|
is set to indicate the error.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH ERRORS
|
|
|
|
.TP
|
2008-07-10 14:54:14 +00:00
|
|
|
.B EINVAL
|
|
|
|
.I buf
|
|
|
|
is NULL.
|
|
|
|
.TP
|
2007-11-29 21:09:52 +00:00
|
|
|
.B ENOENT
|
|
|
|
No user corresponding to
|
|
|
|
.IR uid .
|
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.B ENOMEM
|
2008-07-10 14:54:14 +00:00
|
|
|
Insufficient memory to allocate
|
|
|
|
.I passwd
|
|
|
|
structure.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH FILES
|
|
|
|
.TP
|
|
|
|
.I /etc/passwd
|
|
|
|
password database file
|
|
|
|
.SH "CONFORMING TO"
|
2006-01-13 09:44:53 +00:00
|
|
|
SVr2.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH BUGS
|
|
|
|
The
|
|
|
|
.BR getpw ()
|
|
|
|
function is dangerous as it may overflow the provided buffer
|
|
|
|
.IR buf .
|
2007-04-12 22:42:49 +00:00
|
|
|
It is obsoleted by
|
2007-05-12 00:30:29 +00:00
|
|
|
.BR getpwuid (3).
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR endpwent (3),
|
|
|
|
.BR fgetpwent (3),
|
|
|
|
.BR getpwent (3),
|
|
|
|
.BR getpwnam (3),
|
|
|
|
.BR getpwuid (3),
|
|
|
|
.BR putpwent (3),
|
|
|
|
.BR setpwent (3),
|
|
|
|
.BR passwd (5)
|