-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaps_proc.go
41 lines (35 loc) · 965 Bytes
/
caps_proc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package caps
/*
#include <sys/capability.h>
#cgo LDFLAGS: -lcap
*/
import "C"
// GetProc() returns a capability set reflecting the capabilities of the
// calling process.
func GetProc() (*Cap, error) {
c_cap, err := C.cap_get_proc()
if c_cap == nil {
return nil, err
}
return create(c_cap), nil
}
// SetProc() sets the capabilities of the calling process.
//
// If any flag is set for any capability not currently permitted for the
// calling process, the function will fail, and the capability state of the
// process will remain unchanged.
func (c Cap) SetProc() error {
r, err := C.cap_set_proc(c.c)
return _err(r, err)
}
// GetPid() returns a capability set reflecting the capabilities of the process
// indicated by pid.
//
// This information can also be obtained from the /proc/<pid>/status file.
func GetPid(pid int) (*Cap, error) {
c_cap, err := C.cap_get_pid(C.int(pid))
if c_cap == nil {
return nil, err
}
return create(c_cap), nil
}