Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit f2ec6f5

Browse files
committed
Explicitly set rw for privileged container.
Signed-off-by: Lantao Liu <[email protected]>
1 parent 5cca6bd commit f2ec6f5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pkg/server/container_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ func clearReadOnly(m *runtimespec.Mount) {
523523
opt = append(opt, o)
524524
}
525525
}
526-
m.Options = opt
526+
m.Options = append(opt, "rw")
527527
}
528528

529529
// addDevices set device mapping without privilege.

pkg/server/container_create_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,14 @@ func TestPrivilegedBindMount(t *testing.T) {
635635
}
636636
spec := g.Spec()
637637
if test.expectedSysFSRO {
638-
checkMount(t, spec.Mounts, "sysfs", "/sys", "sysfs", []string{"ro"}, nil)
638+
checkMount(t, spec.Mounts, "sysfs", "/sys", "sysfs", []string{"ro"}, []string{"rw"})
639639
} else {
640-
checkMount(t, spec.Mounts, "sysfs", "/sys", "sysfs", nil, []string{"ro"})
640+
checkMount(t, spec.Mounts, "sysfs", "/sys", "sysfs", []string{"rw"}, []string{"ro"})
641641
}
642642
if test.expectedCgroupFSRO {
643-
checkMount(t, spec.Mounts, "cgroup", "/sys/fs/cgroup", "cgroup", []string{"ro"}, nil)
643+
checkMount(t, spec.Mounts, "cgroup", "/sys/fs/cgroup", "cgroup", []string{"ro"}, []string{"rw"})
644644
} else {
645-
checkMount(t, spec.Mounts, "cgroup", "/sys/fs/cgroup", "cgroup", nil, []string{"ro"})
645+
checkMount(t, spec.Mounts, "cgroup", "/sys/fs/cgroup", "cgroup", []string{"rw"}, []string{"ro"})
646646
}
647647
}
648648
}

0 commit comments

Comments
 (0)