瀏覽代碼

Fix btrfs subvolume snapshot dir perms for user namespaces

Make sure btrfs mounted subvolumes are owned properly when a remapped
root exists (user namespaces are enabled, for example)

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
Phil Estes 9 年之前
父節點
當前提交
72e65e8793
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      daemon/graphdriver/btrfs/btrfs.go

+ 8 - 0
daemon/graphdriver/btrfs/btrfs.go

@@ -266,6 +266,14 @@ func (d *Driver) Create(id, parent, mountLabel string) error {
 		}
 		}
 	}
 	}
 
 
+	// if we have a remapped root (user namespaces enabled), change the created snapshot
+	// dir ownership to match
+	if rootUID != 0 || rootGID != 0 {
+		if err := os.Chown(path.Join(subvolumes, id), rootUID, rootGID); err != nil {
+			return err
+		}
+	}
+
 	return label.Relabel(path.Join(subvolumes, id), mountLabel, false)
 	return label.Relabel(path.Join(subvolumes, id), mountLabel, false)
 }
 }