GETPWUID(3)GETPWUID(3)NAME
getpwuid, getpwnam, getpwent, setpwent, endpwent, setpwfile - user
database access
SYNOPSIS
#include <sys/types.h>
#include <pwd.h>
struct passwd *getpwuid(uid_t uid)
struct passwd *getpwnam(const char *name)
(ALSO AVAILABLE IN BSD)
struct passwd *getpwent(void);
void setpwent(void);
void endpwent(void);
void setpwfile(char *name);
DESCRIPTION
The getpwuid and getpwnam functions both return a pointer to a passwd
structure containing an entry from the system's user (password)
database with a matching numeric user ID (uid) or a user login name
(name).
The passwd structure is defined in the header <pwd.h> and includes the
following members:
Member Type Member Name Description
char * pw_name Login name.
uid_t pw_uid Numerical user ID.
gid_t pw_gid Numerical group ID.
char * pw_dir Pathname of home directory.
char * pw_shell Initial user (shell) program.
char * pw_passwd User password. (BSD only; not
POSIX-compliant)
The passwd structure may contain more implementation-specific members
than those listed here;see passwd(5) for more information.
The BSD routines setpwent, getpwent, endpwent, and setpwfile may be
used to scan the user database sequentially. setpwent resets the
current user password structure to the first in the database, getpwent
reads and returns the next user password entry, and endpwent closes the
user password database when processing is complete. In addition,
setpwfile may be called to set the database to that given in file name,
which is a file in passwd(5) format. Setpwfile doesn't close the
previous password file; endpwent should be used before setpwfile.
NOTES
The value returned points to a static area; if the information is to be
saved, it must be copied.
RETURN VALUE
A NULL pointer is returned on error or if the requested entry is not
found.
FILES
/etc/passwd - if NetInfo is not running, or if YellowPages is enabled.
SEE ALSOgetlogin(3), getgrent(3), lookupd(8), netinfo(5), passwd(5)7th Edition August 1, 1992 GETPWUID(3)