diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-22 05:26:54 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-22 05:26:54 +0900 |
| commit | c5f59c5488cc529a5a7c7a89e1da56c2b44db16c (patch) | |
| tree | b99985bcc6c2bdf569ce7dd676cc12271ae91a2e /container/capability.go | |
| parent | fcd9becf9a611867ad75b3425776433ad4b19951 (diff) | |
container/syscall: export prctl wrapper
This is useful as package "syscall" does not provide such a wrapper. This change also improves error handling to fully conform to the manpage.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/capability.go')
| -rw-r--r-- | container/capability.go | 37 |
1 files changed, 3 insertions, 34 deletions
diff --git a/container/capability.go b/container/capability.go index f41bffa7..11d95b3d 100644 --- a/container/capability.go +++ b/container/capability.go @@ -49,41 +49,10 @@ func capset(hdrp *capHeader, datap *[2]capData) error { } // capBoundingSetDrop drops a capability from the calling thread's capability bounding set. -func capBoundingSetDrop(cap uintptr) error { - r, _, errno := syscall.Syscall( - syscall.SYS_PRCTL, - syscall.PR_CAPBSET_DROP, - cap, 0, - ) - if r != 0 { - return errno - } - return nil -} +func capBoundingSetDrop(cap uintptr) error { return Prctl(syscall.PR_CAPBSET_DROP, cap, 0) } // capAmbientClearAll clears the ambient capability set of the calling thread. -func capAmbientClearAll() error { - r, _, errno := syscall.Syscall( - syscall.SYS_PRCTL, - PR_CAP_AMBIENT, - PR_CAP_AMBIENT_CLEAR_ALL, 0, - ) - if r != 0 { - return errno - } - return nil -} +func capAmbientClearAll() error { return Prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0) } // capAmbientRaise adds to the ambient capability set of the calling thread. -func capAmbientRaise(cap uintptr) error { - r, _, errno := syscall.Syscall( - syscall.SYS_PRCTL, - PR_CAP_AMBIENT, - PR_CAP_AMBIENT_RAISE, - cap, - ) - if r != 0 { - return errno - } - return nil -} +func capAmbientRaise(cap uintptr) error { return Prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, cap) } |
