|
@@ -73,13 +73,17 @@ func untarHandler(tarArchive io.Reader, dest string, options *archive.TarOptions
|
|
|
options.ExcludePatterns = []string{}
|
|
|
}
|
|
|
|
|
|
- idMapping := idtools.NewIDMappingsFromMaps(options.UIDMaps, options.GIDMaps)
|
|
|
- rootIDs := idMapping.RootPair()
|
|
|
+ // If dest is inside a root then directory is created within chroot by extractor.
|
|
|
+ // This case is only currently used by cp.
|
|
|
+ if dest == root {
|
|
|
+ idMapping := idtools.NewIDMappingsFromMaps(options.UIDMaps, options.GIDMaps)
|
|
|
+ rootIDs := idMapping.RootPair()
|
|
|
|
|
|
- dest = filepath.Clean(dest)
|
|
|
- if _, err := os.Stat(dest); os.IsNotExist(err) {
|
|
|
- if err := idtools.MkdirAllAndChownNew(dest, 0755, rootIDs); err != nil {
|
|
|
- return err
|
|
|
+ dest = filepath.Clean(dest)
|
|
|
+ if _, err := os.Stat(dest); os.IsNotExist(err) {
|
|
|
+ if err := idtools.MkdirAllAndChownNew(dest, 0755, rootIDs); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|