1CAP_INIT(3)                Linux Programmer's Manual               CAP_INIT(3)
2
3
4

NAME

6       cap_init, cap_free, cap_dup - capability data object storage management
7

SYNOPSIS

9       #include <sys/capability.h>
10
11       cap_t cap_init(void);
12
13       int cap_free(void *obj_d);
14
15       cap_t cap_dup(cap_t cap_p);
16
17       Link with -lcap.
18

DESCRIPTION

20       The  capabilities  associated  with  a file or process are never edited
21       directly.  Instead, working storage is allocated to contain a represen‐
22       tation  of  the  capability state.  Capabilities are edited and manipu‐
23       lated only within this working storage area.  Once editing of the capa‐
24       bility  state  is  complete,  the  updated  capability state is used to
25       replace the capability state associated with the file or process.
26
27       cap_init() creates a capability state in working storage and returns  a
28       pointer  to  the  capability state.  The initial value of all flags are
29       cleared.  The caller should free any releasable memory, when the  capa‐
30       bility  state  in  working  storage  is  no longer required, by calling
31       cap_free() with the cap_t as an argument.
32
33       cap_free() liberates any releasable memory that has been  allocated  to
34       the capability state identified by obj_d.  The obj_d argument may iden‐
35       tify either a cap_t  entity,  or  a  char *  entity  allocated  by  the
36       cap_to_text() function.
37
38       cap_dup() returns a duplicate capability state in working storage given
39       by the source  object  cap_p,  allocating  any  memory  necessary,  and
40       returning a pointer to the newly created capability state.  Once dupli‐
41       cated, no operation on either capability state affects the other in any
42       way.   When  the  duplicated  capability state in working storage is no
43       longer required, the caller should free any releasable memory by  call‐
44       ing cap_free() with the cap_t as an argument.
45

RETURN VALUE

47       cap_init()  and  cap_dup() return a non-NULL value on success, and NULL
48       on failure.
49
50       cap_free() returns zero on success, and -1 on failure.
51
52       On failure, errno is set to EINVAL or ENOMEM.
53

CONFORMING TO

55       These functions are specified in the withdrawn POSIX.1e draft  specifi‐
56       cation.
57

SEE ALSO

59       libcap(3),     cap_clear(3),     cap_copy_ext(3),     cap_from_text(3),
60       cap_get_file(3), cap_get_proc(3), capabilities(7)
61
62
63
64                                  2008-05-11                       CAP_INIT(3)
Impressum