unix: add support to get/set Linux capabilities

Add wrappers for Getcap/Setcap on Linux as well as some related types
and consts.

Change-Id: I07764c2e64717214850ea3cbdc238e313d1e38c4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183218
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Tobias Klauser
2019-06-21 15:33:39 +00:00
committed by Tobias Klauser
parent 06bbe82148
commit 943d5127bd
42 changed files with 1004 additions and 2 deletions
+13
View File
@@ -48,6 +48,7 @@ package unix
#include <sys/utsname.h>
#include <sys/wait.h>
#include <linux/bpf.h>
#include <linux/capability.h>
#include <linux/errqueue.h>
#include <linux/fanotify.h>
#include <linux/filter.h>
@@ -1991,3 +1992,15 @@ const (
BPF_FD_TYPE_UPROBE = C.BPF_FD_TYPE_UPROBE
BPF_FD_TYPE_URETPROBE = C.BPF_FD_TYPE_URETPROBE
)
// Capabilities
type CapUserHeader C.struct___user_cap_header_struct
type CapUserData C.struct___user_cap_data_struct
const (
LINUX_CAPABILITY_VERSION_1 = C._LINUX_CAPABILITY_VERSION_1
LINUX_CAPABILITY_VERSION_2 = C._LINUX_CAPABILITY_VERSION_2
LINUX_CAPABILITY_VERSION_3 = C._LINUX_CAPABILITY_VERSION_3
)