mirror of
https://github.com/containers/podman.git
synced 2025-06-18 15:39:08 +08:00
Merge pull request #19002 from giuseppe/skip-devices-userns
specgen: raise error with --device-cgroup-rule in a userns
This commit is contained in:
@ -255,7 +255,10 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
|
||||
s.HostDeviceList = userDevices
|
||||
|
||||
// set the devices cgroup when not running in a user namespace
|
||||
if !inUserNS && !s.Privileged {
|
||||
if isRootless && len(s.DeviceCgroupRule) > 0 {
|
||||
return nil, fmt.Errorf("device cgroup rules are not supported in rootless mode or in a user namespace")
|
||||
}
|
||||
if !isRootless && !s.Privileged {
|
||||
for _, dev := range s.DeviceCgroupRule {
|
||||
g.AddLinuxResourcesDevice(true, dev.Type, dev.Major, dev.Minor, dev.Access)
|
||||
}
|
||||
|
@ -785,7 +785,11 @@ EOF
|
||||
}
|
||||
|
||||
@test "podman run --device-cgroup-rule tests" {
|
||||
skip_if_rootless "cannot add devices in rootless mode"
|
||||
if is_rootless; then
|
||||
run_podman 125 run --device-cgroup-rule="b 7:* rmw" --rm $IMAGE
|
||||
is "$output" "Error: device cgroup rules are not supported in rootless mode or in a user namespace"
|
||||
return
|
||||
fi
|
||||
|
||||
run_podman run --device-cgroup-rule="b 7:* rmw" --rm $IMAGE
|
||||
run_podman run --device-cgroup-rule="c 7:* rmw" --rm $IMAGE
|
||||
|
Reference in New Issue
Block a user