cap_dup






cap_init, cap_free, cap_dup − capability data object storage
management

#include<sys/capability.h>

cap_tcap_init(void);

);int cap_free(void *obj_d

);cap_t cap_dup(cap_t cap_p

Link with −lcap.

The capabilities associated with a file or process are never
edited directly.  Instead, working storage is allocated to
contain a representation of the capability state.
Capabilities are edited and manipulated only within this
working storage area.  Once editing of the capability state
is complete, the updated capability state is used to replace
the capability state associated with the file or process.

     creates a capability state in working storage and
returns a pointer to the capability state.  The initial
value of all flags are cleared.  The caller should free any
releasable memory, when the capability state in working
storage is no longer required, by calling with the cap_t as
an argument.

     liberates any releasable memory that has been allocated
to the capability state identified by The obj_d argument may
identify either a cap_t entity, or a char* entity allocated
by the function.

     returns a duplicate capability state in working storage
given by the source object allocating any memory necessary,
and returning a pointer to the newly created capability
state.  Once duplicated, no operation on either capability
state affects the other in any way.  When the duplicated
capability state in working storage is no longer required,
the caller should free any releasable memory by calling with
the cap_t as an argument.

and return a non‐NULL value on success, and NULL on failure.

     returns zero on success, and −1 on failure.

     On failure, errno is set to or

These functions are specified in the withdrawn POSIX.1e
draft specification.













                             ‐2‐