From 039978640fc463d47fdf152b594d2b1e3095e21e Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 6 Jul 2021 12:54:16 -0700 Subject: [PATCH] fix: honor system umask for file creates (#12601) use 0666 os.FileMode to honor system umask --- cmd/format-erasure.go | 4 ++-- cmd/fs-v1-multipart.go | 2 +- cmd/tier-journal.go | 2 +- internal/ioutil/append-file_windows.go | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/format-erasure.go b/cmd/format-erasure.go index 2913ee6df..eff43ccef 100644 --- a/cmd/format-erasure.go +++ b/cmd/format-erasure.go @@ -242,7 +242,7 @@ func formatErasureMigrateV1ToV2(export, version string) error { if err != nil { return err } - return ioutil.WriteFile(formatPath, b, 0644) + return ioutil.WriteFile(formatPath, b, 0666) } // Migrates V2 for format.json to V3 (Flat hierarchy for multipart) @@ -284,7 +284,7 @@ func formatErasureMigrateV2ToV3(export, version string) error { if err != nil { return err } - return ioutil.WriteFile(formatPath, b, 0644) + return ioutil.WriteFile(formatPath, b, 0666) } // countErrs - count a specific error. diff --git a/cmd/fs-v1-multipart.go b/cmd/fs-v1-multipart.go index 80f832ee4..ef1bc3319 100644 --- a/cmd/fs-v1-multipart.go +++ b/cmd/fs-v1-multipart.go @@ -241,7 +241,7 @@ func (fs *FSObjects) NewMultipartUpload(ctx context.Context, bucket, object stri return "", err } - if err = ioutil.WriteFile(pathJoin(uploadIDDir, fs.metaJSONFile), fsMetaBytes, 0644); err != nil { + if err = ioutil.WriteFile(pathJoin(uploadIDDir, fs.metaJSONFile), fsMetaBytes, 0666); err != nil { logger.LogIf(ctx, err) return "", err } diff --git a/cmd/tier-journal.go b/cmd/tier-journal.go index 7dacd0533..15fb632fc 100644 --- a/cmd/tier-journal.go +++ b/cmd/tier-journal.go @@ -255,7 +255,7 @@ func (jd *tierDiskJournal) Open() error { } var err error - jd.file, err = os.OpenFile(jd.JournalPath(), os.O_APPEND|os.O_CREATE|os.O_WRONLY|writeMode, 0644) + jd.file, err = os.OpenFile(jd.JournalPath(), os.O_APPEND|os.O_CREATE|os.O_WRONLY|writeMode, 0666) if err != nil { return err } diff --git a/internal/ioutil/append-file_windows.go b/internal/ioutil/append-file_windows.go index 5430d3fb0..d916bb218 100644 --- a/internal/ioutil/append-file_windows.go +++ b/internal/ioutil/append-file_windows.go @@ -26,13 +26,13 @@ import ( // AppendFile - appends the file "src" to the file "dst" func AppendFile(dst string, src string, osync bool) error { - appendFile, err := lock.Open(dst, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) + appendFile, err := lock.Open(dst, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666) if err != nil { return err } defer appendFile.Close() - srcFile, err := lock.Open(src, os.O_RDONLY, 0644) + srcFile, err := lock.Open(src, os.O_RDONLY, 0666) if err != nil { return err }