Always mount sysfs as rw
.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
8fec0469d9
commit
279fa853a6
@ -662,7 +662,7 @@ func setOCIBindMountsPrivileged(g *generate.Generator) {
|
|||||||
spec := g.Spec()
|
spec := g.Spec()
|
||||||
// clear readonly for /sys and cgroup
|
// clear readonly for /sys and cgroup
|
||||||
for i, m := range spec.Mounts {
|
for i, m := range spec.Mounts {
|
||||||
if spec.Mounts[i].Destination == "/sys" && !spec.Root.Readonly {
|
if spec.Mounts[i].Destination == "/sys" {
|
||||||
clearReadOnly(&spec.Mounts[i])
|
clearReadOnly(&spec.Mounts[i])
|
||||||
}
|
}
|
||||||
if m.Type == "cgroup" {
|
if m.Type == "cgroup" {
|
||||||
|
@ -605,7 +605,6 @@ func TestGenerateContainerMounts(t *testing.T) {
|
|||||||
func TestPrivilegedBindMount(t *testing.T) {
|
func TestPrivilegedBindMount(t *testing.T) {
|
||||||
for desc, test := range map[string]struct {
|
for desc, test := range map[string]struct {
|
||||||
privileged bool
|
privileged bool
|
||||||
readonlyRootFS bool
|
|
||||||
expectedSysFSRO bool
|
expectedSysFSRO bool
|
||||||
expectedCgroupFSRO bool
|
expectedCgroupFSRO bool
|
||||||
}{
|
}{
|
||||||
@ -618,16 +617,9 @@ func TestPrivilegedBindMount(t *testing.T) {
|
|||||||
expectedSysFSRO: false,
|
expectedSysFSRO: false,
|
||||||
expectedCgroupFSRO: false,
|
expectedCgroupFSRO: false,
|
||||||
},
|
},
|
||||||
"sysfs should mount as 'ro' if root filrsystem is readonly": {
|
|
||||||
privileged: true,
|
|
||||||
readonlyRootFS: true,
|
|
||||||
expectedSysFSRO: true,
|
|
||||||
expectedCgroupFSRO: false,
|
|
||||||
},
|
|
||||||
} {
|
} {
|
||||||
t.Logf("TestCase %q", desc)
|
t.Logf("TestCase %q", desc)
|
||||||
g := generate.New()
|
g := generate.New()
|
||||||
g.SetRootReadonly(test.readonlyRootFS)
|
|
||||||
c := newTestCRIService()
|
c := newTestCRIService()
|
||||||
c.addOCIBindMounts(&g, nil, "")
|
c.addOCIBindMounts(&g, nil, "")
|
||||||
if test.privileged {
|
if test.privileged {
|
||||||
|
Loading…
Reference in New Issue
Block a user