diff options
| author | Paul Buetow <paul@buetow.org> | 2024-02-13 19:20:18 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-02-13 19:20:18 +0200 |
| commit | 161e55dc76ee0d3ac52fea8473de5cffebd2bfd9 (patch) | |
| tree | 5efcc214330b6b1b260c4680790fc278b39275c9 /internal/flags/flags.go | |
| parent | 6c1335b3538dabc82b4931d4bf13a36f86c4666e (diff) | |
forgot to add the flags package
Diffstat (limited to 'internal/flags/flags.go')
| -rw-r--r-- | internal/flags/flags.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/flags/flags.go b/internal/flags/flags.go new file mode 100644 index 0000000..674f22f --- /dev/null +++ b/internal/flags/flags.go @@ -0,0 +1,34 @@ +package flags + +import ( + "flag" + "unsafe" + + bpf "github.com/aquasecurity/libbpfgo" +) + +type Flags struct { + UidFilter int +} + +func New() (flags Flags) { + flag.IntVar(&flags.UidFilter, "uid", 0, "Filter for processes with UID") + flag.Parse() + return flags +} + +func (flags Flags) SetBPF(bpfModule *bpf.Module) error { + flagsMap, err := bpfModule.GetMap("flags_map") + if err != nil { + return err + } + + flagsValues := struct { + UidFilter int32 + }{ + UidFilter: int32(flags.UidFilter), + } + + key := uint32(1) + return flagsMap.Update(unsafe.Pointer(&key), unsafe.Pointer(&flagsValues)) +} |
