Skip to content

Commit

Permalink
Fix calculating path for copying ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
kvaps committed Dec 23, 2021
1 parent 7065921 commit 0700c32
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/util/fs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,23 +905,23 @@ func CopyFileOrSymlink(src string, destDir string, root string) error {
if err != nil {
return errors.Wrap(err, "copying file")
}
err = CopyOwnership(src, destDir)
err = CopyOwnership(src, destDir, root)
if err != nil {
return errors.Wrap(err, "copying ownership")
}
return nil
}

// CopyOwnership copies the file or directory ownership recursively at src to dest
func CopyOwnership(src string, destDir string) error {
func CopyOwnership(src string, destDir string, root string) error {
return filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if IsSymlink(info) {
return nil
}
relPath, err := filepath.Rel(filepath.Dir(src), path)
relPath, err := filepath.Rel(root, src)
if err != nil {
return err
}
Expand Down Expand Up @@ -955,9 +955,7 @@ func CopyOwnership(src string, destDir string) error {
return errors.Wrap(err, "reading ownership")
}
stat := info.Sys().(*syscall.Stat_t)
err = os.Chown(destPath, int(stat.Uid), int(stat.Gid))

return nil
return os.Chown(destPath, int(stat.Uid), int(stat.Gid))
})
}

Expand Down

0 comments on commit 0700c32

Please sign in to comment.