From 8296826da5b372a4f7b344173b1dea753f8bd14b Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Mon, 8 Apr 2019 15:08:08 +1000 Subject: [PATCH] specconv: always set "type: bind" in case of MS_BIND We discovered in umoci that setting a dummy type of "none" would result in file-based bind-mounts no longer working properly, which is caused by a restriction for when specconv will change the device type to "bind" to work around rootfs_linux.go's ... issues. However, bind-mounts don't have a type (and Linux will ignore any type specifier you give it) because the type is copied from the source of the bind-mount. So we should always overwrite it to avoid user confusion. Signed-off-by: Aleksa Sarai --- libcontainer/specconv/spec_linux.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libcontainer/specconv/spec_linux.go b/libcontainer/specconv/spec_linux.go index f68cac01..d98444ad 100644 --- a/libcontainer/specconv/spec_linux.go +++ b/libcontainer/specconv/spec_linux.go @@ -277,9 +277,10 @@ func createLibcontainerMount(cwd string, m specs.Mount) *configs.Mount { source := m.Source device := m.Type if flags&unix.MS_BIND != 0 { - if device == "" { - device = "bind" - } + // Any "type" the user specified is meaningless (and ignored) for + // bind-mounts -- so we set it to "bind" because rootfs_linux.go + // (incorrectly) relies on this for some checks. + device = "bind" if !filepath.IsAbs(source) { source = filepath.Join(cwd, m.Source) }