-
Notifications
You must be signed in to change notification settings - Fork 7
/
caplib.h
21 lines (15 loc) · 878 Bytes
/
caplib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* Tony Cheneau <[email protected]> */
/* this code is heavily borrowed from the iputils project */
#include <sys/prctl.h>
#include <sys/capability.h>
extern int limit_capabilities(void);
extern int drop_capabilities(void);
static int enable_capability_raw(void);
static int disable_capability_raw(void);
static int enable_capability_admin(void);
static int disable_capability_admin(void);
extern int modify_capability(cap_value_t, cap_flag_value_t);
static inline int enable_capability_raw(void) { return modify_capability(CAP_NET_RAW, CAP_SET); }
static inline int disable_capability_raw(void) { return modify_capability(CAP_NET_RAW, CAP_CLEAR); }
static inline int enable_capability_admin(void) { return modify_capability(CAP_NET_ADMIN, CAP_SET); }
static inline int disable_capability_admin(void) { return modify_capability(CAP_NET_ADMIN, CAP_CLEAR); }