Skip to content

Commit

Permalink
update file permissions to 0644
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com>
  • Loading branch information
spiffcs committed Sep 21, 2021
1 parent 93d00dc commit 9a87c21
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/logger/logrus.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
prefixed "github.com/x-cray/logrus-prefixed-formatter"
)

var defaultLogFilePermissions = 0644

// LogrusConfig contains all configurable values for the Logrus logger
type LogrusConfig struct {
EnableConsole bool
Expand Down Expand Up @@ -38,15 +40,15 @@ func NewLogrusLogger(cfg LogrusConfig) *LogrusLogger {
var output io.Writer
switch {
case cfg.EnableConsole && cfg.EnableFile:
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE, 0755)
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE, defaultLogFilePermissions)
if err != nil {
panic(fmt.Errorf("unable to setup log file: %w", err))
}
output = io.MultiWriter(os.Stderr, logFile)
case cfg.EnableConsole:
output = os.Stderr
case cfg.EnableFile:
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE, 0755)
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE, defaultLogFilePermissions)
if err != nil {
panic(fmt.Errorf("unable to setup log file: %w", err))
}
Expand Down

0 comments on commit 9a87c21

Please sign in to comment.