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

Better errors when kernel does not support auditing #33

Merged
merged 1 commit into from
May 3, 2018
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Added

- Added better error messages for when `NewAuditClient` fails due to the
Linux kernel not supporting auditing (CONFIG_AUDIT=n). #32

### Changed

### Deprecated
Expand Down
7 changes: 6 additions & 1 deletion audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ func newAuditClient(netlinkGroups uint32, resp io.Writer) (*AuditClient, error)

netlink, err := NewNetlinkClient(syscall.NETLINK_AUDIT, netlinkGroups, buf, resp)
if err != nil {
return nil, err
switch err {
case syscall.EINVAL, syscall.EPROTONOSUPPORT, syscall.EAFNOSUPPORT:
return nil, errors.Wrap(err, "audit not supported by kernel")
default:
return nil, errors.Wrap(err, "failed to open audit netlink socket")
}
}

return &AuditClient{Netlink: netlink}, nil
Expand Down
3 changes: 1 addition & 2 deletions audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ import (
)

// This can be run inside of Docker with:
// docker run -it --rm -v `pwd`:/go/src/github.com/elastic/go-libaudit \
// --pid=host --privileged golang:1.8.3 /bin/bash
// docker run -it --rm -v `pwd`:/go/src/github.com/elastic/go-libaudit --pid=host --privileged golang:1.10.1 /bin/bash

var (
hexdump = flag.Bool("hexdump", false, "dump kernel responses to stdout in hexdump -C format")
Expand Down