getgrent getgrent_r getgrnam getgrnam_r getgrgid getgrgid_r setgroupent setgrent endgrent - group database operations
Lb libc
struct group { char *gr_name; /* group name */ char *gr_passwd; /* group password */ gid_t gr_gid; /* group id */ char **gr_mem; /* group members */ };
The functions
getgrnam ();
and
getgrgid ();
search the group database for the given group name pointed to by
Fa name
or the group id pointed to by
Fa gid ,
respectively, returning the first one encountered.
Identical group
names or group gids may result in undefined behavior.
The
getgrent ();
function
sequentially reads the group database and is intended for programs
that wish to step through the complete list of groups.
The functions
getgrent_r (,);
getgrnam_r (,);
and
getgrgid_r ();
are thread-safe versions of
getgrent (,);
getgrnam (,);
and
getgrgid (,);
respectively.
The caller must provide storage for the results of the search in
the
Fa grp ,
Fa buffer ,
Fa bufsize ,
and
Fa result
arguments.
When these functions are successful, the
Fa grp
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
These functions will open the group file for reading, if necessary.
The
setgroupent ();
function
opens the file, or rewinds it if it is already open.
If
Fa stayopen
is non-zero, file descriptors are left open, significantly speeding
functions subsequent calls.
This functionality is unnecessary for
getgrent ();
as it does not close its file descriptors by default.
It should also
be noted that it is dangerous for long-running programs to use this
functionality as the group file may be updated.
The
setgrent ();
function
is identical to
setgroupent ();
with an argument of zero.
The
endgrent ();
function
closes any open files.
The functions
setgroupent ();
and
setgrent ();
return the value 1 if successful, otherwise the value
0 is returned.
The functions
endgrent ();
and
setgrfile ();
have no return value.
The functions
getgrent (,);
getgrent_r (,);
endgrent (,);
setgroupent (,);
and
setgrent ();
are fairly useless in a networked environment and should be
avoided, if possible.
The
getgrent ();
and
getgrent_r ();
functions
make no attempt to suppress duplicate information if multiple
sources are specified in
nsswitch.conf5.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |