Skip to content

Commit e15889c

Browse files
committed
Fix file perms
1 parent 7e9526d commit e15889c

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

.github/workflows/build-monitoring.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ jobs:
5151
export PATH=`pwd`/bin:$PATH
5252
cohctl init monitoring -y
5353
cohctl start monitoring
54-
sleep 30
55-
for container in `docker ps -a | sed 1d | awk '{print $1}'`; do
56-
docker logs $container
57-
done
58-
docker ps
54+
sleep 15
5955
netstat -an | grep 9090
6056
netstat -an | grep 3000
6157
cohctl get monitoring

pkg/cmd/monitoring.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,15 +420,16 @@ func monitoringNotValid(message string) error {
420420
func writeFileContents(base, file string, content []byte) error {
421421
destPath := filepath.Join(base, file)
422422

423-
if err := os.WriteFile(destPath, content, 0600); err != nil {
423+
// #nosec G306 -- file is meant to be readable by docker on Linux
424+
if err := os.WriteFile(destPath, content, 0644); err != nil {
424425
return fmt.Errorf("error writing file %s: %w", destPath, err)
425426
}
426427

427428
return nil
428429
}
429430

430431
func ensureDirectory(directory string) error {
431-
err := utils.EnsureDirectory(directory)
432+
err := utils.EnsureDirectoryWithPerms(directory, 0755)
432433
if err != nil {
433434
return fmt.Errorf("unable to create directory: %s, %v", directory, err)
434435
}

pkg/utils/utils.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/oracle/coherence-cli/pkg/constants"
1818
"go.uber.org/zap"
1919
"go.uber.org/zap/zapcore"
20+
"io/fs"
2021
"os"
2122
"path/filepath"
2223
"regexp"
@@ -149,9 +150,14 @@ func GetJSONPathResults(jsonData []byte, jsonPath string) (string, error) {
149150

150151
// EnsureDirectory ensures a directory exists and if not then will create it.
151152
func EnsureDirectory(directory string) error {
153+
return EnsureDirectoryWithPerms(directory, 0700)
154+
}
155+
156+
// EnsureDirectoryWithPerms ensures a directory exists and if not then will create it with specific permissions.
157+
func EnsureDirectoryWithPerms(directory string, perm fs.FileMode) error {
152158
if _, err := os.Stat(directory); err != nil {
153159
if os.IsNotExist(err) {
154-
err = os.Mkdir(directory, 0700)
160+
err = os.Mkdir(directory, perm)
155161
if err != nil {
156162
return GetError("unable to create directory "+directory, err)
157163
}

0 commit comments

Comments
 (0)