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

Commit d3c9069

Browse files
authored
Merge pull request #1605 from dweomer/backport/1.4/selinux-relabel-dev-shm
[release/1.4 backport] selinux: relabel /dev/shm
2 parents f7fce60 + 1ec7ede commit d3c9069

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

pkg/server/container_create_unix.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ func (c *criService) containerMounts(sandboxID string, config *runtime.Container
101101
sandboxDevShm = devShm
102102
}
103103
mounts = append(mounts, &runtime.Mount{
104-
ContainerPath: devShm,
105-
HostPath: sandboxDevShm,
106-
Readonly: false,
104+
ContainerPath: devShm,
105+
HostPath: sandboxDevShm,
106+
Readonly: false,
107+
SelinuxRelabel: sandboxDevShm != devShm,
107108
})
108109
}
109110
return mounts

pkg/server/container_create_unix_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,10 @@ func TestContainerMounts(t *testing.T) {
457457
Readonly: true,
458458
},
459459
{
460-
ContainerPath: "/dev/shm",
461-
HostPath: filepath.Join(testStateDir, sandboxesDir, testSandboxID, "shm"),
462-
Readonly: false,
460+
ContainerPath: "/dev/shm",
461+
HostPath: filepath.Join(testStateDir, sandboxesDir, testSandboxID, "shm"),
462+
Readonly: false,
463+
SelinuxRelabel: true,
463464
},
464465
},
465466
},
@@ -482,9 +483,10 @@ func TestContainerMounts(t *testing.T) {
482483
Readonly: false,
483484
},
484485
{
485-
ContainerPath: "/dev/shm",
486-
HostPath: filepath.Join(testStateDir, sandboxesDir, testSandboxID, "shm"),
487-
Readonly: false,
486+
ContainerPath: "/dev/shm",
487+
HostPath: filepath.Join(testStateDir, sandboxesDir, testSandboxID, "shm"),
488+
Readonly: false,
489+
SelinuxRelabel: true,
488490
},
489491
},
490492
},
@@ -555,9 +557,10 @@ func TestContainerMounts(t *testing.T) {
555557
Readonly: false,
556558
},
557559
{
558-
ContainerPath: "/dev/shm",
559-
HostPath: filepath.Join(testStateDir, sandboxesDir, testSandboxID, "shm"),
560-
Readonly: false,
560+
ContainerPath: "/dev/shm",
561+
HostPath: filepath.Join(testStateDir, sandboxesDir, testSandboxID, "shm"),
562+
Readonly: false,
563+
SelinuxRelabel: true,
561564
},
562565
},
563566
},

0 commit comments

Comments
 (0)