diff options
author | Hironori Shiina <shiina.hironori@jp.fujitsu.com> | 2022-03-03 21:39:14 -0500 |
---|---|---|
committer | Hironori Shiina <shiina.hironori@jp.fujitsu.com> | 2022-03-07 18:12:17 -0500 |
commit | d2f77c256836e8a1a562d56eed7d92fdb18a2f76 (patch) | |
tree | 0236f36d71cb52bb342da22abce030a84152f546 /pkg/specgen | |
parent | 4a242b1327fb34e6cac6c1686afb3370901180d3 (diff) | |
download | podman-d2f77c256836e8a1a562d56eed7d92fdb18a2f76.tar.gz podman-d2f77c256836e8a1a562d56eed7d92fdb18a2f76.tar.bz2 podman-d2f77c256836e8a1a562d56eed7d92fdb18a2f76.zip |
Set default rule at the head of device configuration
The default rule should be set at the head of device configuration.
Otherwise, rules for user devices are overridden by the default rule so
that any access to the user devices are denied.
Signed-off-by: Hironori Shiina <shiina.hironori@jp.fujitsu.com>
Diffstat (limited to 'pkg/specgen')
-rw-r--r-- | pkg/specgen/generate/oci.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/specgen/generate/oci.go b/pkg/specgen/generate/oci.go index 8b3550e36..1cc3a463f 100644 --- a/pkg/specgen/generate/oci.go +++ b/pkg/specgen/generate/oci.go @@ -332,6 +332,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 @@ -363,7 +368,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) } |