Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bb2007c

Browse files
committedAug 9, 2018
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 a064c29 commit bb2007c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎tools/download.go

Lines changed: 8 additions & 1 deletion
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)
Please sign in to comment.