File Audit Mode 0000 bug (#15759)

* adding file mode changes

* add changelog

* adding error

* adding fmt changes
This commit is contained in:
akshya96
2022-06-03 09:17:41 -07:00
committed by GitHub
parent 1e8004d810
commit 0e8bcc15cc
3 changed files with 56 additions and 1 deletions

View File

@@ -78,9 +78,21 @@ func Factory(ctx context.Context, conf *audit.BackendConfig) (audit.Backend, err
if err != nil {
return nil, err
}
if m != 0 {
switch m {
case 0:
// if mode is 0000, then do not modify file mode
if path != "stdout" && path != "discard" {
fileInfo, err := os.Stat(path)
if err != nil {
return nil, err
}
mode = fileInfo.Mode()
}
default:
mode = os.FileMode(m)
}
}
b := &Backend{