Skip to content

Commit c767dc4

Browse files
brianshumatejefferai
authored andcommitted
Conditionally set file audit log mode (hashicorp#3649)
1 parent 77fc890 commit c767dc4

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

builtin/audit/file/backend.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ func Factory(conf *audit.BackendConfig) (audit.Backend, error) {
7575
if err != nil {
7676
return nil, err
7777
}
78-
mode = os.FileMode(m)
78+
if m != 0 {
79+
mode = os.FileMode(m)
80+
}
7981
}
8082

8183
b := &Backend{
@@ -247,13 +249,15 @@ func (b *Backend) open() error {
247249
}
248250

249251
// Change the file mode in case the log file already existed. We special
250-
// case /dev/null since we can't chmod it
252+
// case /dev/null since we can't chmod it and bypass if the mode is zero
251253
switch b.path {
252254
case "/dev/null":
253255
default:
254-
err = os.Chmod(b.path, b.mode)
255-
if err != nil {
256-
return err
256+
if b.mode != 0 {
257+
err = os.Chmod(b.path, b.mode)
258+
if err != nil {
259+
return err
260+
}
257261
}
258262
}
259263

website/source/docs/audit/file.html.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Following are the configuration options available for the backend.
7777
<span class="param-flags">optional</span>
7878
A string containing an octal number representing the bit pattern
7979
for the file mode, similar to `chmod`. This option defaults to
80-
`0600`.
80+
`0600`. Specifying mode of `0000` will disable Vault's setting any mode on the file.
8181
</li>
8282
<li>
8383
<span class="param">format</span>

0 commit comments

Comments
 (0)