Skip to content

Commit

Permalink
Merge pull request #3 from kolyshkin/fix-apply-amb
Browse files Browse the repository at this point in the history
Apply: fix ambient caps error handling
  • Loading branch information
kolyshkin authored Jul 22, 2024
2 parents 96ee438 + 4d79446 commit 042f19f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions capability_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,14 @@ func (c *capsV3) Apply(kind CapType) (err error) {
if c.Get(AMBIENT, i) {
action = pr_CAP_AMBIENT_RAISE
}
err := prctl(pr_CAP_AMBIENT, action, uintptr(i), 0, 0)
// Ignore EINVAL as not supported on kernels before 4.3
if errno, ok := err.(syscall.Errno); ok && errno == syscall.EINVAL {
err = nil
continue
err = prctl(pr_CAP_AMBIENT, action, uintptr(i), 0, 0)
if err != nil {
// Ignore EINVAL as not supported on kernels before 4.3
if errno, ok := err.(syscall.Errno); ok && errno == syscall.EINVAL {
err = nil
continue
}
return
}
}
}
Expand Down

0 comments on commit 042f19f

Please sign in to comment.