Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit e9374d6

Browse files
committed
use os.Chmod over syscall.Umask
1 parent 8989c69 commit e9374d6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pkg/util/tar_utils.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,11 @@ import (
2222
"os"
2323
"path/filepath"
2424
"strings"
25-
"syscall"
2625

2726
"github.com/sirupsen/logrus"
2827
)
2928

3029
func unpackTar(tr *tar.Reader, path string) error {
31-
// drop the umask temporarily to 0, so we can create all files with correct permissions
32-
// otherwise the default (022) will cause file permission inconsistencies
33-
oldMask := syscall.Umask(0)
34-
defer syscall.Umask(oldMask)
3530
for {
3631
header, err := tr.Next()
3732
if err == io.EOF {
@@ -85,6 +80,12 @@ func unpackTar(tr *tar.Reader, path string) error {
8580
logrus.Errorf("Error opening file %s", target)
8681
return err
8782
}
83+
// manually set permissions on file, since the default umask (022) will interfere
84+
err = os.Chmod(target, mode)
85+
if err != nil {
86+
logrus.Errorf("Error updating file permissions on %s", target)
87+
return err
88+
}
8889
_, err = io.Copy(currFile, tr)
8990
if err != nil {
9091
return err

0 commit comments

Comments
 (0)