Skip to content

Commit

Permalink
Merge pull request #4260 from nalind/inheritable-capabilities-1.20
Browse files Browse the repository at this point in the history
[release-1.20] do not set the inheritable capabilities
  • Loading branch information
openshift-merge-robot authored Sep 19, 2022
2 parents b1c8ef9 + 77fdaa4 commit 6796205
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion chroot/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ func setCapabilities(spec *specs.Spec, keepCaps ...string) error {
capMap := map[capability.CapType][]string{
capability.BOUNDING: spec.Process.Capabilities.Bounding,
capability.EFFECTIVE: spec.Process.Capabilities.Effective,
capability.INHERITABLE: spec.Process.Capabilities.Inheritable,
capability.INHERITABLE: {},
capability.PERMITTED: spec.Process.Capabilities.Permitted,
capability.AMBIENT: spec.Process.Capabilities.Ambient,
}
Expand Down
6 changes: 0 additions & 6 deletions run_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1861,9 +1861,6 @@ func setupCapAdd(g *generate.Generator, caps ...string) error {
if err := g.AddProcessCapabilityEffective(cap); err != nil {
return errors.Wrapf(err, "error adding %q to the effective capability set", cap)
}
if err := g.AddProcessCapabilityInheritable(cap); err != nil {
return errors.Wrapf(err, "error adding %q to the inheritable capability set", cap)
}
if err := g.AddProcessCapabilityPermitted(cap); err != nil {
return errors.Wrapf(err, "error adding %q to the permitted capability set", cap)
}
Expand All @@ -1882,9 +1879,6 @@ func setupCapDrop(g *generate.Generator, caps ...string) error {
if err := g.DropProcessCapabilityEffective(cap); err != nil {
return errors.Wrapf(err, "error removing %q from the effective capability set", cap)
}
if err := g.DropProcessCapabilityInheritable(cap); err != nil {
return errors.Wrapf(err, "error removing %q from the inheritable capability set", cap)
}
if err := g.DropProcessCapabilityPermitted(cap); err != nil {
return errors.Wrapf(err, "error removing %q from the permitted capability set", cap)
}
Expand Down
13 changes: 13 additions & 0 deletions tests/run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -608,3 +608,16 @@ _EOF
uncolored="$output"
[ "$colored" != "$uncolored" ]
}

@test "run-inheritable-capabilities" {
skip_if_no_runtime

_prefetch alpine

run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
cid=$output
run_buildah run $cid grep ^CapInh: /proc/self/status
expect_output "CapInh: 0000000000000000"
run_buildah run --cap-add=ALL $cid grep ^CapInh: /proc/self/status
expect_output "CapInh: 0000000000000000"
}

0 comments on commit 6796205

Please sign in to comment.