From 416e06a36ca69f4595c644d290a2f3825bb7ea5c Mon Sep 17 00:00:00 2001 From: Josh Powers Date: Mon, 6 Jun 2022 08:55:37 -0600 Subject: [PATCH] fix: remove full access permissions In the directory_monitor and ceph tests, there are a number of places where directories or test files were created with full permissions. This is not the right thing to do in these cases. Instead, use the default file (644) and folder (755) permissions that are commonly used. --- plugins/inputs/ceph/ceph_test.go | 2 +- plugins/inputs/directory_monitor/directory_monitor.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/inputs/ceph/ceph_test.go b/plugins/inputs/ceph/ceph_test.go index 43381662b18e2..1f0b58ad30df0 100644 --- a/plugins/inputs/ceph/ceph_test.go +++ b/plugins/inputs/ceph/ceph_test.go @@ -183,7 +183,7 @@ func createTestFiles(dir string, st *SockTest) error { writeFile := func(prefix string, i int) error { f := sockFile(prefix, i) fpath := filepath.Join(dir, f) - return os.WriteFile(fpath, []byte(""), 0777) + return os.WriteFile(fpath, []byte(""), 0644) } return tstFileApply(st, writeFile) } diff --git a/plugins/inputs/directory_monitor/directory_monitor.go b/plugins/inputs/directory_monitor/directory_monitor.go index 6834d25f471df..1bb9ebb0b9bc9 100644 --- a/plugins/inputs/directory_monitor/directory_monitor.go +++ b/plugins/inputs/directory_monitor/directory_monitor.go @@ -316,7 +316,7 @@ func (monitor *DirectoryMonitor) Init() error { // Finished directory can be created if not exists for convenience. if _, err := os.Stat(monitor.FinishedDirectory); os.IsNotExist(err) { - err = os.Mkdir(monitor.FinishedDirectory, 0777) + err = os.Mkdir(monitor.FinishedDirectory, 0755) if err != nil { return err } @@ -328,7 +328,7 @@ func (monitor *DirectoryMonitor) Init() error { // If an error directory should be used but has not been configured yet, create one ourselves. if monitor.ErrorDirectory != "" { if _, err := os.Stat(monitor.ErrorDirectory); os.IsNotExist(err) { - err := os.Mkdir(monitor.ErrorDirectory, 0777) + err := os.Mkdir(monitor.ErrorDirectory, 0755) if err != nil { return err }