getpwent getpwent_r getpwnam getpwnam_r getpwuid getpwuid_r setpassent setpwent endpwent - password database operations
Lb libc
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
getpwnam ();
and
getpwuid ();
search the password database for the given login name or user uid,
respectively, always returning the first one encountered.
The
getpwent ();
function
sequentially reads the password database and is intended for programs
that wish to process the complete list of users.
The functions
getpwent_r (,);
getpwnam_r (,);
and
getpwuid_r ();
are thread-safe versions of
getpwent (,);
getpwnam (,);
and
getpwuid (,);
respectively.
The caller must provide storage for the results of the search in
the
Fa pwd ,
Fa buffer ,
Fa bufsize ,
and
Fa result
arguments.
When these functions are successful, the
Fa pwd
argument will be filled-in, and a pointer to that argument will be
stored in
Fa result .
If an entry is not found or an error occurs,
Fa result
will be set to
NULL
The
setpassent ();
function
accomplishes two purposes.
First, it causes
getpwent ();
to ``rewind'' to the beginning of the database.
Additionally, if
Fa stayopen
is non-zero, file descriptors are left open, significantly speeding
up subsequent accesses for all of the routines.
(This latter functionality is unnecessary for
getpwent ();
as it does not close its file descriptors by default.)
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
setpwent ();
function
is identical to
setpassent ();
with an argument of zero.
The
endpwent ();
function
closes any open files.
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 `*'
The
setpassent ();
function returns 0 on failure and 1 on success.
The
endpwent ();
and
setpwent ();
functions
have no return value.
The functions
getpwent (,);
getpwent_r (,);
endpwent (,);
setpassent (,);
and
setpwent ();
are fairly useless in a networked environment and should be
avoided, if possible.
The
getpwent ();
and
getpwent_r ();
functions
make no attempt to suppress duplicate information if multiple
sources are specified in
nsswitch.conf5.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |