From bb2007cb13750fa955da8d12a0ad307652e77a19 Mon Sep 17 00:00:00 2001 From: Matteo Suppo Date: Thu, 9 Aug 2018 14:20:12 +0200 Subject: [PATCH] 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 --- tools/download.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/download.go b/tools/download.go index a40649139..705156ea9 100644 --- a/tools/download.go +++ b/tools/download.go @@ -423,7 +423,8 @@ func extractTarGz(body []byte, location string) (string, error) { info := header.FileInfo() // Create parent folder - if err = os.MkdirAll(filepath.Dir(path), info.Mode()); err != nil { + dirmode := info.Mode() | os.ModeDir | 0700 + if err = os.MkdirAll(filepath.Dir(path), dirmode); err != nil { return location, err } @@ -514,6 +515,12 @@ func extractBz2(body []byte, location string) (string, error) { path := filepath.Join(location, strings.Replace(header.Name, basedir, "", -1)) info := header.FileInfo() + // Create parent folder + dirmode := info.Mode() | os.ModeDir | 0700 + if err = os.MkdirAll(filepath.Dir(path), dirmode); err != nil { + return location, err + } + if info.IsDir() { if err = os.MkdirAll(path, info.Mode()); err != nil { return location, err