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

Audit: eventlogger sink node reopen on SIGHUP #23598

Merged
merged 5 commits into from
Oct 11, 2023
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
44 changes: 28 additions & 16 deletions builtin/audit/file/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,27 +391,39 @@ func (b *Backend) open() error {
}

func (b *Backend) Reload(_ context.Context) error {
switch b.path {
case stdout, discard:
// When there are nodes created in the map, use the eventlogger behavior.
if len(b.nodeMap) > 0 {
for _, n := range b.nodeMap {
if n.Type() == eventlogger.NodeTypeSink {
return n.Reopen()
}
}

return nil
}
} else {
// old non-eventlogger behavior
switch b.path {
case stdout, discard:
return nil
}

b.fileLock.Lock()
defer b.fileLock.Unlock()
b.fileLock.Lock()
defer b.fileLock.Unlock()

if b.f == nil {
return b.open()
}
if b.f == nil {
return b.open()
}

err := b.f.Close()
// Set to nil here so that even if we error out, on the next access open()
// will be tried
b.f = nil
if err != nil {
return err
}
err := b.f.Close()
// Set to nil here so that even if we error out, on the next access open()
// will be tried
b.f = nil
if err != nil {
return err
}

return b.open()
return b.open()
}
}

func (b *Backend) Invalidate(_ context.Context) {
Expand Down
3 changes: 3 additions & 0 deletions changelog/23598.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
audit: Fix bug reopening 'file' audit devices on SIGHUP.
```
Loading