Go to main content

man pages section 3: Extended Library Functions, Volume 3

Exit Print View

Updated: Thursday, June 13, 2019
 
 

Ppriv (3PROC)

Name

Pcred, Ppriv, Psetcred, Psetpriv, Psetzoneid - get and set credentials and privileges

Synopsis

#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);

Description

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.

Return Values

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.

Errors

On failure, these errno values may be set:

EAGAIN

Process has been lost to control, need Preopen()

EBUSY

Process is not stopped (Psetrun())

EINTR

Signal received while waiting for stop

EINVAL

Invalid argument

ENOENT

The victim process has terminated

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
Unsafe

See Also

libproc.h(3HEAD), libproc(3LIB), Pcreate(3PROC), Pgrab(3PROC), proc(5)