Pcred, Ppriv, Psetcred, Psetpriv, Psetzoneid - get and set credentials and privileges
#include <libproc.h>
int Pcred(ps_prochandle_t *Pr, prcred_t *pcred, int ngroups);
ssize_t Ppriv(ps_prochandle_t *Pr, prpriv_t *pprv, size_t size);
int Psetcred(ps_prochandle_t *Pr, const prcred_t *pcred);
int Psetpriv(ps_prochandle_t *Pr, prpriv_t *pprv);
The Pr argument identifies a victim process or core file attached to the controlling process by the create and grab interfaces. For more information, see the Pcreate(3PROC) and Pgrab(3PROC) man pages.
The Pcred() function retrieves the process or core file credentials which includes real, effective, and saved user IDs, real, effective, and saved group IDs, and supplementary group IDs. The ngroups argument specifies the number of supplementary group entries allocated in the cred structure of the caller. It should equal zero or one unless extra space has been allocated for the group list by the caller, like this:
pcred = malloc(sizeof (prcred_t) + (ngroups - 1) * sizeof (gid_t));
The Ppriv() function retrieves the process or core file privileges. The size argument is the size in bytes of the pprv buffer of the caller. If the size argument is zero, the Ppriv() function returns the actual size needed to allocate a buffer and to call the Ppriv() function again.
The Psetcred() function sets the credentials of the victim process from the correctly-constructed pcred buffer which includes the pr_ngroups member.
The Psetpriv() function sets the victim process's privileges from the correctly constructed pprv buffer.
On successful completion, the Pcred() function returns 0. The number of supplementary group ids for the victim is returned in the pr_ngroups member of the prcred_t structure regardless of the value of the ngroups argument. On error, it returns -1 and sets errno to indicate the error.
On successful completion, the Ppriv() function returns the number of bytes read into the pprv buffer. If the size argument is zero, the Ppriv() function returns the size needed to allocate a buffer and to call the Ppriv() function again. On error, it returns -1 and sets errno to indicate the error.
On successful completion, the Psetcred() and Psetpriv() functions return 0. On error, they return -1 and set errno to indicate the error.
On failure, these errno values may be set:
Process has been lost to control, need Preopen()
Process is not stopped (Psetrun())
Signal received while waiting for stop
Invalid argument
The victim process has terminated
See attributes(7) for descriptions of the following attributes:
|
libproc.h(3HEAD), libproc(3LIB), Pcreate(3PROC), Pgrab(3PROC), proc(5)