mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
chrootarchive: don't create parent dirs outside of chroot
If chroot is used with a special root directory then create
destination directory within chroot. This works automatically
already due to extractor creating parent paths and is only
used currently with cp where parent paths are actually required
and error will be shown to user before reaching this point.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 52d285184068998c22632bfb869f6294b5613a58)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit 80f1169eca
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
03f1c3d78f
commit
cec4e69813
1 changed files with 10 additions and 6 deletions
|
@ -73,6 +73,9 @@ func untarHandler(tarArchive io.Reader, dest string, options *archive.TarOptions
|
|||
options.ExcludePatterns = []string{}
|
||||
}
|
||||
|
||||
// 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()
|
||||
|
||||
|
@ -82,6 +85,7 @@ func untarHandler(tarArchive io.Reader, dest string, options *archive.TarOptions
|
|||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
r := io.NopCloser(tarArchive)
|
||||
if decompress {
|
||||
|
|
Loading…
Reference in a new issue