mirror of https://github.com/containers/podman.git
Merge pull request #12618 from giuseppe/dev-cgroup-add-default-devices
oci: configure the devices cgroup with default devices
This commit is contained in:
commit
d1c91c128e
|
@ -325,9 +325,13 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
|
|||
}
|
||||
s.HostDeviceList = s.Devices
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
for k, v := range s.WeightDevice {
|
||||
statT := unix.Stat_t{}
|
||||
|
|
|
@ -119,4 +119,11 @@ var _ = Describe("Podman run device", func() {
|
|||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
})
|
||||
|
||||
It("podman run cannot access non default devices", func() {
|
||||
session := podmanTest.Podman([]string{"run", "-v /dev:/dev-host", ALPINE, "head", "-1", "/dev-host/kmsg"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Not(Exit(0)))
|
||||
})
|
||||
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue