diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-26 07:44:07 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-26 07:44:07 +0900 |
| commit | 18644d90bef239100f3a89982f27b4b6792068d2 (patch) | |
| tree | cb14220c82196170a77372466fcbd15baf9007cb /sandbox/syscall.go | |
| parent | 52fcc48ac141147324c3baac0e87ea49e8c2ca09 (diff) | |
sandbox: wrap capset syscall
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'sandbox/syscall.go')
| -rw-r--r-- | sandbox/syscall.go | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/sandbox/syscall.go b/sandbox/syscall.go index a92fa173..7ddb5137 100644 --- a/sandbox/syscall.go +++ b/sandbox/syscall.go @@ -1,17 +1,16 @@ package sandbox -import "syscall" +import ( + "syscall" + "unsafe" +) const ( O_PATH = 0x200000 PR_SET_NO_NEW_PRIVS = 0x26 - PR_CAP_AMBIENT = 47 - PR_CAP_AMBIENT_CLEAR_ALL = 4 - CAP_SYS_ADMIN = 0x15 - CAP_SETPCAP = 8 ) const ( @@ -28,6 +27,37 @@ func SetDumpable(dumpable uintptr) error { 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 // EINTR error. This appears to be required even though we install all // signal handlers with SA_RESTART: see #22838, #38033, #38836, #40846. |
