From b4ec7f5b23ce93324366a8cce51dcb8deddd9050 Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Fri, 26 Feb 2016 21:50:50 -0500 Subject: [PATCH] Fix ownership of non-existing parent dir During "COPY" or other tar unpack operations, a target/destination parent dir might not exist and should be created with ownership of the root in the right context (including remapped root when user namespaces are enabled) Docker-DCO-1.1-Signed-off-by: Phil Estes (github: estesp) --- archive/archive.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archive/archive.go b/archive/archive.go index 1281683..e81f587 100644 --- a/archive/archive.go +++ b/archive/archive.go @@ -660,7 +660,7 @@ loop: parent := filepath.Dir(hdr.Name) parentPath := filepath.Join(dest, parent) if _, err := os.Lstat(parentPath); err != nil && os.IsNotExist(err) { - err = system.MkdirAll(parentPath, 0777) + err = idtools.MkdirAllNewAs(parentPath, 0777, remappedRootUID, remappedRootGID) if err != nil { return err }