mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-22 09:49:35 +00:00
dev: Revert "Don't ignore container mounts based on their path"
This reverts commit 08909b2213
.
We should not be passing any bind-mounts from /dev, /sys and /proc.
Mounting these from the host inside the container does not make
sense as these files are relevant to the host OS.
Fixes #219
Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
parent
1c7a02e73d
commit
10c596a4ff
@ -290,7 +290,7 @@ func (c *Container) createContainersDirs() error {
|
|||||||
func (c *Container) mountSharedDirMounts(hostSharedDir, guestSharedDir string) ([]Mount, error) {
|
func (c *Container) mountSharedDirMounts(hostSharedDir, guestSharedDir string) ([]Mount, error) {
|
||||||
var sharedDirMounts []Mount
|
var sharedDirMounts []Mount
|
||||||
for idx, m := range c.mounts {
|
for idx, m := range c.mounts {
|
||||||
if m.Type != "bind" {
|
if isSystemMount(m.Destination) || m.Type != "bind" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,18 @@ import (
|
|||||||
|
|
||||||
var rootfsDir = "rootfs"
|
var rootfsDir = "rootfs"
|
||||||
|
|
||||||
|
var systemMountPrefixes = []string{"/proc", "/dev", "/sys"}
|
||||||
|
|
||||||
|
func isSystemMount(m string) bool {
|
||||||
|
for _, p := range systemMountPrefixes {
|
||||||
|
if m == p || strings.HasPrefix(m, p+"/") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func major(dev uint64) int {
|
func major(dev uint64) int {
|
||||||
return int((dev >> 8) & 0xfff)
|
return int((dev >> 8) & 0xfff)
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,30 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestIsSystemMount(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
mnt string
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{"/sys", true},
|
||||||
|
{"/sys/", true},
|
||||||
|
{"/sys//", true},
|
||||||
|
{"/sys/fs", true},
|
||||||
|
{"/sys/fs/", true},
|
||||||
|
{"/sys/fs/cgroup", true},
|
||||||
|
{"/sysfoo", false},
|
||||||
|
{"/home", false},
|
||||||
|
{"/dev/block/", true},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
result := isSystemMount(test.mnt)
|
||||||
|
if result != test.expected {
|
||||||
|
t.Fatalf("Expected result for path %s : %v, got %v", test.mnt, test.expected, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestMajorMinorNumber(t *testing.T) {
|
func TestMajorMinorNumber(t *testing.T) {
|
||||||
devices := []string{"/dev/zero", "/dev/net/tun"}
|
devices := []string{"/dev/zero", "/dev/net/tun"}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user