Skip to content

Commit a67bf75

Browse files
committed
Set correct permissions when downloading tool
The extraction of some tools failed because the parent folder of some files wasn't created with useful permissions. Here we correctly set the permission such as the folder has exec and write permission for the current user
1 parent b4f41f4 commit a67bf75

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/download.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ func extractTarGz(body []byte, location string) (string, error) {
423423
info := header.FileInfo()
424424

425425
// Create parent folder
426-
if err = os.MkdirAll(filepath.Dir(path), info.Mode()); err != nil {
426+
dirmode := info.Mode() | os.ModeDir | 0700
427+
if err = os.MkdirAll(filepath.Dir(path), dirmode); err != nil {
427428
return location, err
428429
}
429430

@@ -514,6 +515,12 @@ func extractBz2(body []byte, location string) (string, error) {
514515
path := filepath.Join(location, strings.Replace(header.Name, basedir, "", -1))
515516
info := header.FileInfo()
516517

518+
// Create parent folder
519+
dirmode := info.Mode() | os.ModeDir | 0700
520+
if err = os.MkdirAll(filepath.Dir(path), dirmode); err != nil {
521+
return location, err
522+
}
523+
517524
if info.IsDir() {
518525
if err = os.MkdirAll(path, info.Mode()); err != nil {
519526
return location, err

0 commit comments

Comments
 (0)