1LIBCAP(3) Linux Programmer's Manual LIBCAP(3)
2
3
4
6 cap_clear, cap_clear_flag, cap_compare, cap_copy_ext, cap_copy_int,
7 cap_free, cap_from_name, cap_from_text, cap_get_fd, cap_get_file,
8 cap_get_flag, cap_get_pid, cap_get_proc, cap_set_fd, cap_set_file,
9 cap_set_flag, cap_set_proc, cap_size, cap_to_name, cap_to_text,
10 cap_get_pid, cap_dup - capability data object manipulation
11
13 #include <sys/capability.h>
14
15 int cap_clear(cap_t cap_p);
16
17 int cap_clear_flag(cap_t cap_p, cap_flag_t flag);
18
19 int cap_compare(cap_t cap_a, cap_t cap_b);
20
21 ssize_t cap_copy_ext(void *ext_p, cap_t cap_p, ssize_t size);
22
23 cap_t cap_copy_int(const void *ext_p);
24
25 int cap_free(void *obj_d);
26
27 int cap_from_name(const char *name, cap_value_t *cap_p);
28
29 cap_t cap_from_text(const char *buf_p);
30
31 cap_t cap_get_fd(int fd);
32
33 cap_t cap_get_file(const char *path_p);
34
35 int cap_get_flag(cap_t cap_p, cap_value_t cap,
36 cap_flag_t flag, cap_flag_value_t *value_p);
37
38 #include <sys/types.h>
39 cap_t cap_get_pid(pid_t pid);
40
41 cap_t cap_get_proc(void);
42
43 int cap_set_fd(int fd, cap_t caps);
44
45 int cap_set_file(const char *path_p, cap_t cap_p);
46
47
48 int cap_set_flag(cap_t cap_p, cap_flag_t flag, int ncap,
49 const cap_value_t *caps, cap_flag_value_t value);
50 int cap_set_proc(cap_t cap_p);
51
52 ssize_t cap_size(cap_t cap_p);
53
54 char *cap_to_name(cap_value_t cap);
55
56 char *cap_to_text(cap_t caps, ssize_t *length_p);
57
58 cap_t cap_get_pid(pid_t pid);
59
60 cap_t cap_dup(cap_t cap_p);
61
62 Link with -lcap.
63
65 These functions work on a capability state held in working storage. A
66 cap_t holds information about the capabilities in each of the three
67 sets, Permitted, Inheritable, and Effective. Each capability in a set
68 may be clear (disabled, 0) or set (enabled, 1).
69
70 These functions work with the following data types:
71
72 cap_value_t identifies a capability, such as CAP_CHOWN.
73
74 cap_flag_t identifies one of the three flags associated with a
75 capability (i.e., it identifies one of the three
76 capability sets). Valid values for this type are
77 CAP_EFFECTIVE, CAP_INHERITABLE or CAP_PERMITTED.
78
79 cap_flag_value_t identifies the setting of a particular capability
80 flag (i.e, the value of a capability in a set).
81 Valid values for this type are CAP_CLEAR(0) or
82 CAP_SET(1).
83
85 The return value is generally specific to the individual function
86 called. On failure, errno is set appropriately.
87
89 These functions are as per the withdrawn POSIX.1e draft specification.
90 The following functions are Linux extensions: cap_clear_flag(),
91 cap_from_name(), cap_to_name(), and cap_compare().
92
94 Please report bugs via:
95
96 https://bugzilla.kernel.org/buglist.cgi?component=lib‐
97 cap&list_id=1047723&product=Tools&resolution=---
98
100 cap_clear(3), cap_copy_ext(3), cap_from_text(3), cap_get_file(3),
101 cap_get_proc(3), cap_init(3), capabilities(7), getpid(2) capsh(1)
102
103
104
105 2020-01-07 LIBCAP(3)