浏览代码

chroot: remount everything as private in new mntns

If parent of the destination path is shared, this
path will be unmounted from the parent ns even if
the path itself is private.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit b511d1f0cabd32ca30c87fa1bbc7ecac283dab39)
Signed-off-by: Victor Vieux <vieux@docker.com>
Tonis Tiigi 8 年之前
父节点
当前提交
a8ffa0128c
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      pkg/chrootarchive/chroot_linux.go

+ 6 - 1
pkg/chrootarchive/chroot_linux.go

@@ -21,7 +21,12 @@ func chroot(path string) (err error) {
 		return fmt.Errorf("Error creating mount namespace before pivot: %v", err)
 	}
 
-	if err := mount.MakeRPrivate(path); err != nil {
+	// make everything in new ns private
+	if err := mount.MakeRPrivate("/"); err != nil {
+		return err
+	}
+	// ensure path is a mountpoint
+	if err := mount.MakePrivate(path); err != nil {
 		return err
 	}