mirror of
https://github.com/containers/podman.git
synced 2025-06-24 03:08:13 +08:00
Merge pull request #20086 from giuseppe/fix-mount-cgroupfs-without-netns
specgen, rootless: fix mount of cgroup without a netns
This commit is contained in:
@ -125,11 +125,12 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
|
||||
}
|
||||
g.AddMount(sysMnt)
|
||||
g.RemoveMount("/sys/fs/cgroup")
|
||||
|
||||
sysFsCgroupMnt := spec.Mount{
|
||||
Destination: "/sys/fs/cgroup",
|
||||
Type: define.TypeBind,
|
||||
Type: "cgroup",
|
||||
Source: "/sys/fs/cgroup",
|
||||
Options: []string{"rprivate", "nosuid", "noexec", "nodev", r, "rbind"},
|
||||
Options: []string{"rprivate", "nosuid", "noexec", "nodev", r},
|
||||
}
|
||||
g.AddMount(sysFsCgroupMnt)
|
||||
if !s.Privileged && isRootless {
|
||||
|
@ -1167,6 +1167,10 @@ EOF
|
||||
# verify that the last /sys/fs/cgroup mount is read-only
|
||||
run_podman run --net=host --cgroupns=host --rm $IMAGE sh -c "grep ' / /sys/fs/cgroup ' /proc/self/mountinfo | tail -n 1"
|
||||
assert "$output" =~ "/sys/fs/cgroup ro"
|
||||
|
||||
# verify that it works also with a cgroupns
|
||||
run_podman run --net=host --cgroupns=private --rm $IMAGE sh -c "grep ' / /sys/fs/cgroup ' /proc/self/mountinfo | tail -n 1"
|
||||
assert "$output" =~ "/sys/fs/cgroup ro"
|
||||
fi
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user