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

feat: resolve compile errors in x-pack/audibeat without cgo #42425

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

//go:build linux
// +build linux
//go:build linux && cgo

package afpacket

Expand Down Expand Up @@ -159,7 +158,7 @@ func (c *dnsCapture) run(ctx context.Context, consumer parent.Consumer) {
}
data, _, err := source.ZeroCopyReadPacketData()
if err != nil {
if err == afpacket.ErrTimeout {
if errors.Is(err, afpacket.ErrTimeout) {
continue
}
c.log.Error("DNS capture error", err)
Expand Down
27 changes: 13 additions & 14 deletions x-pack/auditbeat/module/system/socket/guess/creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ import (
"github.com/elastic/elastic-agent-libs/mapstr"
)

/*
struct mq_attr {
long mq_flags;
long mq_maxmsg;
long mq_msgsize;
long mq_curmsgs;
long __reserved[4];
};
*/
import "C"
type MqAttr struct {
_ int
Maxmsg int
Msgsize int
_ int
}

/*
creds guess discovers the offsets of (E)UID/(E)GID fields within a
Expand Down Expand Up @@ -120,7 +116,10 @@ func (g *guessStructCreds) Terminate() error {

// Extract receives the struct cred dump and discovers the offsets.
func (g *guessStructCreds) Extract(ev interface{}) (mapstr.M, bool) {
raw := ev.([]byte)
raw, ok := ev.([]byte)
if !ok {
return nil, false
}
if len(raw) != credDumpBytes {
return nil, false
}
Expand Down Expand Up @@ -157,9 +156,9 @@ func (g *guessStructCreds) Trigger() error {
if err != nil {
return err
}
attr := C.struct_mq_attr{
mq_maxmsg: 1,
mq_msgsize: 8,
attr := MqAttr{
Maxmsg: 1,
Msgsize: 8,
}
mqd, _, errno := syscall.Syscall6(unix.SYS_MQ_OPEN,
uintptr(unsafe.Pointer(name)),
Expand Down
Loading