]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/caps.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
11 #include <linux/types.h> /* workaround for libcap < 2.17 bug */
12 #include <sys/capability.h>
14 extern int lxc_caps_down(void);
15 extern int lxc_caps_up(void);
16 extern int lxc_ambient_caps_up(void);
17 extern int lxc_ambient_caps_down(void);
18 extern int lxc_caps_init(void);
19 extern int lxc_caps_last_cap(void);
20 extern bool lxc_proc_cap_is_set(cap_value_t cap
, cap_flag_t flag
);
21 extern bool lxc_file_cap_is_set(const char *path
, cap_value_t cap
,
24 static inline int lxc_caps_down(void)
29 static inline int lxc_caps_up(void)
34 static inline int lxc_ambient_caps_up(void)
39 static inline int lxc_ambient_caps_down(void)
44 static inline int lxc_caps_init(void)
49 static inline int lxc_caps_last_cap(void)
54 typedef int cap_value_t
;
55 typedef int cap_flag_t
;
56 static inline bool lxc_proc_cap_is_set(cap_value_t cap
, cap_flag_t flag
)
61 static inline bool lxc_file_cap_is_set(const char *path
, cap_value_t cap
,
68 #define lxc_priv(__lxc_function) \
71 int __ret, __ret2, ___errno = 0; \
72 __ret = lxc_caps_up(); \
75 __ret = __lxc_function; \
78 __ret2 = lxc_caps_down(); \
80 __ret ? errno = ___errno, __ret : __ret2; \
83 #define lxc_unpriv(__lxc_function) \
86 int __ret, __ret2, ___errno = 0; \
87 __ret = lxc_caps_down(); \
90 __ret = __lxc_function; \
93 __ret2 = lxc_caps_up(); \
95 __ret ? errno = ___errno, __ret : __ret2; \