Blame doc/cap_init.3

Packit 3a1417
.\"
Packit 3a1417
.\" written by Andrew Main <zefram@dcs.warwick.ac.uk>
Packit 3a1417
.\"
Packit 3a1417
.TH CAP_INIT 3 "2008-05-11" "" "Linux Programmer's Manual"
Packit 3a1417
.SH NAME
Packit 3a1417
cap_init, cap_free, cap_dup \- capability data object storage management
Packit 3a1417
.SH SYNOPSIS
Packit 3a1417
.B #include <sys/capability.h>
Packit 3a1417
.sp
Packit 3a1417
.B cap_t cap_init(void);
Packit 3a1417
.sp
Packit 3a1417
.BI "int cap_free(void *" obj_d );
Packit 3a1417
.sp
Packit 3a1417
.BI "cap_t cap_dup(cap_t " cap_p );
Packit 3a1417
.sp
Packit 3a1417
Link with \fI-lcap\fP.
Packit 3a1417
.SH DESCRIPTION
Packit 3a1417
The capabilities associated with a file or process are never edited
Packit 3a1417
directly.  Instead, working storage is allocated to contain a
Packit 3a1417
representation of the capability state.  Capabilities are edited and
Packit 3a1417
manipulated only within this working storage area.  Once editing of
Packit 3a1417
the capability state is complete, the updated capability state is used
Packit 3a1417
to replace the capability state associated with the file or process.
Packit 3a1417
.PP
Packit 3a1417
.BR cap_init ()
Packit 3a1417
creates a capability state in working storage and returns a pointer to
Packit 3a1417
the capability state.  The initial value of all flags are cleared.  The
Packit 3a1417
caller should free any releasable memory, when the capability state in
Packit 3a1417
working storage is no longer required, by calling
Packit 3a1417
.BR cap_free ()
Packit 3a1417
with the 
Packit 3a1417
.I cap_t
Packit 3a1417
as an argument.
Packit 3a1417
.PP
Packit 3a1417
.BR cap_free ()
Packit 3a1417
liberates any releasable memory that has been allocated to the
Packit 3a1417
capability state identified by
Packit 3a1417
.IR obj_d .
Packit 3a1417
The
Packit 3a1417
.I obj_d
Packit 3a1417
argument may identify either a
Packit 3a1417
.I cap_t
Packit 3a1417
entity, or a
Packit 3a1417
.I char *
Packit 3a1417
entity allocated by the
Packit 3a1417
.BR cap_to_text ()
Packit 3a1417
function.
Packit 3a1417
.PP
Packit 3a1417
.BR cap_dup ()
Packit 3a1417
returns a duplicate capability state in working storage given by the
Packit 3a1417
source object
Packit 3a1417
.IR cap_p , 
Packit 3a1417
allocating any memory necessary, and returning a
Packit 3a1417
pointer to the newly created capability state.  Once duplicated, no
Packit 3a1417
operation on either capability state affects the other in any way.
Packit 3a1417
When the duplicated capability state in working storage is no longer required,
Packit 3a1417
the caller should free any releasable memory by calling
Packit 3a1417
.BR cap_free ()
Packit 3a1417
with the 
Packit 3a1417
.I cap_t
Packit 3a1417
as an argument.
Packit 3a1417
.SH "RETURN VALUE"
Packit 3a1417
.BR cap_init ()
Packit 3a1417
and
Packit 3a1417
.BR cap_dup ()
Packit 3a1417
return a non-NULL value on success, and NULL on failure.
Packit 3a1417
.PP
Packit 3a1417
.BR cap_free ()
Packit 3a1417
returns zero on success, and \-1 on failure.
Packit 3a1417
.PP
Packit 3a1417
On failure,
Packit 3a1417
.I errno
Packit 3a1417
is set to
Packit 3a1417
.BR EINVAL
Packit 3a1417
or
Packit 3a1417
.BR ENOMEM .
Packit 3a1417
.SH "CONFORMING TO"
Packit 3a1417
These functions are specified in the withdrawn POSIX.1e draft specification.
Packit 3a1417
.SH "SEE ALSO"
Packit 3a1417
.BR libcap (3),
Packit 3a1417
.BR cap_clear (3),
Packit 3a1417
.BR cap_copy_ext (3),
Packit 3a1417
.BR cap_from_text (3),
Packit 3a1417
.BR cap_get_file (3),
Packit 3a1417
.BR cap_get_proc (3),
Packit 3a1417
.BR capabilities (7)