Skip to content

Commit

Permalink
Merge pull request containers#13480 from TomSweeneyRedHat/dev/tsweene…
Browse files Browse the repository at this point in the history
…y/fujiback

[v4.0] Backport Set default rule at the head of dev config
  • Loading branch information
openshift-merge-robot authored Mar 13, 2022
2 parents 717edd7 + 61f6e13 commit ec2fdb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/specgen/generate/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
}
// Devices

// set the default rule at the beginning of device configuration
if !inUserNS && !s.Privileged {
g.AddLinuxResourcesDevice(false, "", nil, nil, "rwm")
}

var userDevices []spec.LinuxDevice
if s.Privileged {
// If privileged, we need to add all the host devices to the
Expand Down Expand Up @@ -356,7 +361,6 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt

// set the devices cgroup when not running in a user namespace
if !inUserNS && !s.Privileged {
g.AddLinuxResourcesDevice(false, "", nil, nil, "rwm")
for _, dev := range s.DeviceCgroupRule {
g.AddLinuxResourcesDevice(true, dev.Type, dev.Major, dev.Minor, dev.Access)
}
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/run_device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ var _ = Describe("Podman run device", func() {
session := podmanTest.Podman([]string{"run", "-q", "--security-opt", "label=disable", "--device", "/dev/kmsg", ALPINE, "test", "-c", "/dev/kmsg"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
if !isRootless() {
session = podmanTest.Podman([]string{"run", "-q", "--security-opt", "label=disable", "--device", "/dev/kmsg", "--cap-add", "SYS_ADMIN", ALPINE, "head", "-n", "1", "/dev/kmsg"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
}
})

It("podman run device rename test", func() {
Expand Down

0 comments on commit ec2fdb1

Please sign in to comment.