Merge pull request #21162 from estesp/copyastar-dir-create
Fix CopyWithTar creation of new destination dir as remapped root
This commit is contained in:
commit
b1d33bd4a2
1 changed files with 9 additions and 1 deletions
|
@ -881,9 +881,17 @@ func (archiver *Archiver) CopyWithTar(src, dst string) error {
|
||||||
if !srcSt.IsDir() {
|
if !srcSt.IsDir() {
|
||||||
return archiver.CopyFileWithTar(src, dst)
|
return archiver.CopyFileWithTar(src, dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if this archiver is set up with ID mapping we need to create
|
||||||
|
// the new destination directory with the remapped root UID/GID pair
|
||||||
|
// as owner
|
||||||
|
rootUID, rootGID, err := idtools.GetRootUIDGID(archiver.UIDMaps, archiver.GIDMaps)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
// Create dst, copy src's content into it
|
// Create dst, copy src's content into it
|
||||||
logrus.Debugf("Creating dest directory: %s", dst)
|
logrus.Debugf("Creating dest directory: %s", dst)
|
||||||
if err := system.MkdirAll(dst, 0755); err != nil {
|
if err := idtools.MkdirAllNewAs(dst, 0755, rootUID, rootGID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logrus.Debugf("Calling TarUntar(%s, %s)", src, dst)
|
logrus.Debugf("Calling TarUntar(%s, %s)", src, dst)
|
||||||
|
|
Loading…
Reference in a new issue