sandbox: wrap capset syscall
Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
52fcc48ac1
commit
18644d90be
@ -1,17 +1,16 @@
|
|||||||
package sandbox
|
package sandbox
|
||||||
|
|
||||||
import "syscall"
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
O_PATH = 0x200000
|
O_PATH = 0x200000
|
||||||
|
|
||||||
PR_SET_NO_NEW_PRIVS = 0x26
|
PR_SET_NO_NEW_PRIVS = 0x26
|
||||||
|
|
||||||
PR_CAP_AMBIENT = 47
|
|
||||||
PR_CAP_AMBIENT_CLEAR_ALL = 4
|
|
||||||
|
|
||||||
CAP_SYS_ADMIN = 0x15
|
CAP_SYS_ADMIN = 0x15
|
||||||
CAP_SETPCAP = 8
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -28,6 +27,37 @@ func SetDumpable(dumpable uintptr) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
_LINUX_CAPABILITY_VERSION_3 = 0x20080522
|
||||||
|
|
||||||
|
PR_CAP_AMBIENT = 47
|
||||||
|
PR_CAP_AMBIENT_CLEAR_ALL = 4
|
||||||
|
|
||||||
|
CAP_SETPCAP = 8
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
capHeader struct {
|
||||||
|
version uint32
|
||||||
|
pid int32
|
||||||
|
}
|
||||||
|
|
||||||
|
capData struct {
|
||||||
|
effective uint32
|
||||||
|
permitted uint32
|
||||||
|
inheritable uint32
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func capset(hdrp *capHeader, datap *[2]capData) error {
|
||||||
|
if _, _, errno := syscall.Syscall(syscall.SYS_CAPSET,
|
||||||
|
uintptr(unsafe.Pointer(hdrp)),
|
||||||
|
uintptr(unsafe.Pointer(&datap[0])), 0); errno != 0 {
|
||||||
|
return errno
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// IgnoringEINTR makes a function call and repeats it if it returns an
|
// IgnoringEINTR makes a function call and repeats it if it returns an
|
||||||
// EINTR error. This appears to be required even though we install all
|
// EINTR error. This appears to be required even though we install all
|
||||||
// signal handlers with SA_RESTART: see #22838, #38033, #38836, #40846.
|
// signal handlers with SA_RESTART: see #22838, #38033, #38836, #40846.
|
||||||
|
Loading…
Reference in New Issue
Block a user