HP-UX Reference (11i v2 07/12) - 3 Library Functions N-Z (vol 7)

p
priv_add(3) priv_add(3)
priv_set_effective()
Sets the effective privilege set of the calling process to the given privilege(s).
privset_add_effective()
Similar to priv_add_effective()
, except that it uses a privilege set type to specify the
privileges to add to the calling process’ effective privilege set.
privset_get()
Returns the privilege set specified by the priv_type argument of the process specified by pid.If
the pid is
0, the calling process’s privilege set is returned. The caller must free the memory allo-
cated for the privilege vector when it is no longer referenced using
privset_free
privset_remove()
Similar to priv_remove()
, except that it uses a privilege set type to specify the privileges to
remove from the calling process’ effective privilege set.
privset_set_effective()
Similar to priv_set_effective
, except that it uses a privilege set type to specify the
privileges to set the calling process’ effective privilege set.
RETURN VALUE
Upon successful completion,
priv_add_effective()
, priv_set_effective(),
priv_remove(), privset_add_effective()
, privset_set_effective()
, and
privset_remove()
return the following values:
0 Successful completion.
-1 Function failed. errno is set to indicate the error.
privset_get() returns the following values:
pointer
Successful completions. Returns a non-null pointer to the privilege vector.
NULL pointer
Function failed. Returns a null pointer and sets errno
to indicate the error.
ERRORS
If any of the following conditions occur, the functions fail and set
errno.
[EINVAL] Invalid parameter or operation.
[ENOMEM] The function failed to allocate sufficient memory for its operation.
[EPERM] The privilege to be set in the effective set is not present in the permitted set. Attempt
to add or remove privileges of a different process fails.
[ESRCH] pid is not valid.
EXAMPLES
#include <sys/privileges.h>
#include <stdio.h>
#include <stdlib.h>
#define priv_list "basic,policy,limit,!cmptread,!fork"
main()
{
if (priv_set_effective(priv_list, ",") )
{
printf("priv_set failed \n");
exit(1);
}
printf("\nThe effective set of the process is %s\n",
priv_set_to_str(privset_get(PRIV_EFFECTIVE, 0), ’,’, PRIV_STR_SHORT));
}
164 Hewlett-Packard Company − 2 − HP-UX 11i Version 2: December 2007 Update