]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/caps.h
2 * lxc: linux Container library
4 * (C) Copyright IBM Corp. 2007, 2008
7 * Daniel Lezcano <daniel.lezcano at free.fr>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 #include <sys/capability.h>
33 extern int lxc_caps_down(void);
34 extern int lxc_caps_up(void);
35 extern int lxc_caps_init(void);
37 extern int lxc_caps_last_cap(void);
39 extern bool lxc_proc_cap_is_set(cap_value_t cap
, cap_flag_t flag
);
40 extern bool lxc_file_cap_is_set(const char *path
, cap_value_t cap
, cap_flag_t flag
);
42 static inline int lxc_caps_down(void) {
45 static inline int lxc_caps_up(void) {
48 static inline int lxc_caps_init(void) {
52 static inline int lxc_caps_last_cap(void) {
56 typedef int cap_value_t
;
57 typedef int cap_flag_t
;
58 static inline bool lxc_proc_cap_is_set(cap_value_t cap
, cap_flag_t flag
) {
62 static inline bool lxc_file_cap_is_set(const char *path
, cap_value_t cap
, cap_flag_t flag
) {
67 #define lxc_priv(__lxc_function) \
70 int __ret, __ret2, ___errno = 0; \
71 __ret = lxc_caps_up(); \
74 __ret = __lxc_function; \
77 __ret2 = lxc_caps_down(); \
78 out: __ret ? errno = ___errno,__ret : __ret2; \
81 #define lxc_unpriv(__lxc_function) \
84 int __ret, __ret2, ___errno = 0; \
85 __ret = lxc_caps_down(); \
88 __ret = __lxc_function; \
91 __ret2 = lxc_caps_up(); \
92 out: __ret ? errno = ___errno,__ret : __ret2; \