Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
| ... | ... |
@@ -711,10 +711,6 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. |
| 711 | 711 |
if !sysInfo.CgroupNamespaces {
|
| 712 | 712 |
warnings = append(warnings, "Your kernel does not support cgroup namespaces. Cgroup namespace setting discarded.") |
| 713 | 713 |
} |
| 714 |
- |
|
| 715 |
- if hostConfig.Privileged && !cgroups.IsCgroup2UnifiedMode() {
|
|
| 716 |
- return warnings, fmt.Errorf("privileged mode is incompatible with private cgroup namespaces on cgroup v1 host. You must run the container in the host cgroup namespace when running privileged mode")
|
|
| 717 |
- } |
|
| 718 | 714 |
} |
| 719 | 715 |
|
| 720 | 716 |
return warnings, nil |
| ... | ... |
@@ -339,10 +339,7 @@ func WithNamespaces(daemon *Daemon, c *container.Container) coci.SpecOpts {
|
| 339 | 339 |
if !cgroupNsMode.Valid() {
|
| 340 | 340 |
return fmt.Errorf("invalid cgroup namespace mode: %v", cgroupNsMode)
|
| 341 | 341 |
} |
| 342 |
- |
|
| 343 |
- // for cgroup v2: unshare cgroupns even for privileged containers |
|
| 344 |
- // https://github.com/containers/libpod/pull/4374#issuecomment-549776387 |
|
| 345 |
- if cgroupNsMode.IsPrivate() && (cgroups.IsCgroup2UnifiedMode() || !c.HostConfig.Privileged) {
|
|
| 342 |
+ if cgroupNsMode.IsPrivate() {
|
|
| 346 | 343 |
nsCgroup := specs.LinuxNamespace{Type: "cgroup"}
|
| 347 | 344 |
setNamespace(s, nsCgroup) |
| 348 | 345 |
} |
| ... | ... |
@@ -114,9 +114,8 @@ func TestCgroupNamespacesRunPrivilegedAndPrivate(t *testing.T) {
|
| 114 | 114 |
skip.If(t, testEnv.IsRemoteDaemon()) |
| 115 | 115 |
skip.If(t, !requirement.CgroupNamespacesEnabled()) |
| 116 | 116 |
|
| 117 |
- // Running with both privileged and cgroupns=private is not allowed |
|
| 118 |
- errStr := "privileged mode is incompatible with private cgroup namespaces on cgroup v1 host. You must run the container in the host cgroup namespace when running privileged mode" |
|
| 119 |
- testCreateFailureWithCgroupNs(t, "private", errStr, container.WithPrivileged(true), container.WithCgroupnsMode("private"))
|
|
| 117 |
+ containerCgroup, daemonCgroup := testRunWithCgroupNs(t, "private", container.WithPrivileged(true), container.WithCgroupnsMode("private"))
|
|
| 118 |
+ assert.Assert(t, daemonCgroup != containerCgroup) |
|
| 120 | 119 |
} |
| 121 | 120 |
|
| 122 | 121 |
func TestCgroupNamespacesRunInvalidMode(t *testing.T) {
|