|
NAMEgetpwent , getpwent_r ,
getpwnam , getpwnam_r ,
getpwuid , getpwuid_r ,
setpassent , setpwent ,
endpwent —
password database operations
LIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <sys/types.h>
#include <pwd.h>
struct passwd *
int
struct passwd *
int
struct passwd *
int
int
void
void
DESCRIPTIONThese functions operate on the password database file which is described in passwd(5). Each entry in the database is defined by the structure passwd found in the include file<pwd.h> :
struct passwd { char *pw_name; /* user name */ char *pw_passwd; /* encrypted password */ uid_t pw_uid; /* user uid */ gid_t pw_gid; /* user gid */ time_t pw_change; /* password change time */ char *pw_class; /* user access class */ char *pw_gecos; /* Honeywell login info */ char *pw_dir; /* home directory */ char *pw_shell; /* default shell */ time_t pw_expire; /* account expiration */ int pw_fields; /* internal: fields filled in */ }; The functions The The functions The It is dangerous for long-running programs to keep the file descriptors open as the database will become out of date if it is updated while the program is running. The The These routines have been written to ``shadow'' the password file,
e.g. allow only certain programs to have access to the encrypted password.
If the process which calls them has an effective uid of 0, the encrypted
password will be returned, otherwise, the password field of the returned
structure will point to the string
‘ RETURN VALUESThe functionsgetpwent (),
getpwnam (), and getpwuid ()
return a valid pointer to a passwd structure on success or
NULL if the entry is not found or if an error occurs.
If an error does occur, errno will be set. Note that
programs must explicitly set errno to zero before
calling any of these functions if they need to distinguish between a
non-existent entry and an error. The functions
getpwent_r (), getpwnam_r (),
and getpwuid_r () return 0 if no error occurred, or an
error number to indicate failure. It is not an error if a matching entry is
not found. (Thus, if result is
NULL and the return value is 0, no matching entry
exists.)
The FILES
COMPATIBILITYThe historic function setpwfile(3), which allowed the specification of alternate password databases, has been deprecated and is no longer available.ERRORSThese routines may fail for any of the errors specified in open(2), dbopen(3), socket(2), and connect(2), in addition to the following:
SEE ALSOgetlogin(2), getgrent(3), nsswitch.conf(5), passwd(5), pwd_mkdb(8), vipw(8), yp(8)STANDARDSThegetpwent (), getpwnam (),
getpwnam_r (), getpwuid (),
getpwuid_r (), setpwent (), and
endpwent () functions conform to
ISO/IEC 9945-1:1996 (“POSIX.1”).
HISTORYThegetpwent (), getpwnam (),
getpwuid (), setpwent (), and
endpwent () functions appeared in
Version 7 AT&T UNIX. The
setpassent () function appeared in
4.3BSD-Reno. The getpwent_r (),
getpwnam_r (), and getpwuid_r ()
functions appeared in FreeBSD 5.1.
BUGSThe functionsgetpwent (),
getpwnam (), and getpwuid (),
leave their results in an internal static object and return a pointer to that
object. Subsequent calls to the same function will modify the same object.
The functions
Visit the GSP FreeBSD Man Page Interface. |