From 72e65e87935e5b82de76a6ef9b8160900f4724b7 Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Thu, 7 Jan 2016 23:05:28 -0500 Subject: [PATCH] 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 (github: estesp) --- daemon/graphdriver/btrfs/btrfs.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/daemon/graphdriver/btrfs/btrfs.go b/daemon/graphdriver/btrfs/btrfs.go index dfe5b549f3..86aa631b75 100644 --- a/daemon/graphdriver/btrfs/btrfs.go +++ b/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) }