mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-27 08:30:22 +00:00
Make chmod on ADDed files
Fixes #3979 Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
This commit is contained in:
+8
-5
@@ -431,9 +431,12 @@ func (b *buildFile) addContext(container *daemon.Container, orig, dest string, r
|
||||
return err
|
||||
}
|
||||
|
||||
chownR := func(destPath string, uid, gid int) error {
|
||||
fixPermsR := func(destPath string, uid, gid int) error {
|
||||
return filepath.Walk(destPath, func(path string, info os.FileInfo, err error) error {
|
||||
if err := os.Lchown(path, uid, gid); err != nil {
|
||||
if err := os.Lchown(path, uid, gid); err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
if err := os.Chmod(path, 0755); err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -450,12 +453,12 @@ func (b *buildFile) addContext(container *daemon.Container, orig, dest string, r
|
||||
return err
|
||||
}
|
||||
for _, file := range files {
|
||||
if err := chownR(filepath.Join(destPath, file.Name()), 0, 0); err != nil {
|
||||
if err := fixPermsR(filepath.Join(destPath, file.Name()), 0, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if err := chownR(destPath, 0, 0); err != nil {
|
||||
if err := fixPermsR(destPath, 0, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -494,7 +497,7 @@ func (b *buildFile) addContext(container *daemon.Container, orig, dest string, r
|
||||
resPath = path.Join(destPath, path.Base(origPath))
|
||||
}
|
||||
|
||||
if err := chownR(resPath, 0, 0); err != nil {
|
||||
if err := fixPermsR(resPath, 0, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user