Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally set file audit log mode #3649

Merged
merged 3 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions builtin/audit/file/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ func Factory(conf *audit.BackendConfig) (audit.Backend, error) {
if err != nil {
return nil, err
}
mode = os.FileMode(m)
if m != 0 {
mode = os.FileMode(m)
}
}

b := &Backend{
Expand Down Expand Up @@ -247,13 +249,15 @@ func (b *Backend) open() error {
}

// Change the file mode in case the log file already existed. We special
// case /dev/null since we can't chmod it
// case /dev/null since we can't chmod it and bypass if the mode is zero
switch b.path {
case "/dev/null":
default:
err = os.Chmod(b.path, b.mode)
if err != nil {
return err
if b.mode != 0 {
err = os.Chmod(b.path, b.mode)
if err != nil {
return err
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion website/source/docs/audit/file.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Following are the configuration options available for the backend.
<span class="param-flags">optional</span>
A string containing an octal number representing the bit pattern
for the file mode, similar to `chmod`. This option defaults to
`0600`.
`0600`. Specifying mode of `0000` will disable Vault's setting any mode on the file.
</li>
<li>
<span class="param">format</span>
Expand Down