PCRED(3PROC) | Process Control Library Functions | PCRED(3PROC) |
Pcred
— obtain
process credentials
Process Control Library (libproc, -lproc)
#include
<libproc.h>
int
Pcred
(struct ps_prochandle *P,
prcred_t *pcrp, int
ngroups);
The
Pcred
()
function obtains the credentials of the process from the handle
P.
The credentials are read into the buffer pointed to
by pcrp. The prcred_t type is
defined in proc(5). It contains
information about the current effective, saved, and real user and group IDs.
It also allows for supplemental groups to be obtained. The
Pcred
()
function will read a number of supplemental groups based on the value of
ngroups. The prcred_t structure only
contains the space for one supplemental group by default. Callers should
ensure that the buffer pointed to by pcrp contains
enough space to include all of the required supplemental groups that are
desired.
Not all process handles have credential information available to them. For example, the handles that come from Pgrab_file(3PROC) have no processes associated with them and thus have no credentials associated with them.
Upon successful completion, the Pcred
()
function returns
0 and updates
the memory at pcrp with the credentials. Otherwise,
-1 is returned
to indicate an error.
See LOCKING in libproc(3LIB).
May 11, 2016 | OmniOS |