From d5532aade0c3f042c5daa7d1c16e7cce2f4b524a Mon Sep 17 00:00:00 2001 From: Ophestra Date: Wed, 2 Jul 2025 00:22:27 +0900 Subject: sandbox/seccomp: native rule slice in helpers These helper functions took FilterPreset as input for ease of integration. This moves them to []NativeRule. Signed-off-by: Ophestra --- sandbox/seccomp/proc.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'sandbox/seccomp/proc.go') diff --git a/sandbox/seccomp/proc.go b/sandbox/seccomp/proc.go index 25417826..51c3bce8 100644 --- a/sandbox/seccomp/proc.go +++ b/sandbox/seccomp/proc.go @@ -13,14 +13,10 @@ const ( ) // New returns an inactive Encoder instance. -func New(presets FilterPreset, flags PrepareFlag) *Encoder { - return &Encoder{newExporter(presets, flags)} -} +func New(rules []NativeRule, flags PrepareFlag) *Encoder { return &Encoder{newExporter(rules, flags)} } // Load loads a filter into the kernel. -func Load(presets FilterPreset, flags PrepareFlag) error { - return preparePreset(-1, presets, flags) -} +func Load(rules []NativeRule, flags PrepareFlag) error { return Prepare(-1, rules, flags) } /* An Encoder writes a BPF program to an output stream. @@ -50,20 +46,20 @@ func (e *Encoder) Close() error { } // NewFile returns an instance of exporter implementing [proc.File]. -func NewFile(presets FilterPreset, flags PrepareFlag) proc.File { - return &File{presets: presets, flags: flags} +func NewFile(rules []NativeRule, flags PrepareFlag) proc.File { + return &File{rules: rules, flags: flags} } // File implements [proc.File] and provides access to the read end of exporter pipe. type File struct { - presets FilterPreset - flags PrepareFlag + rules []NativeRule + flags PrepareFlag proc.BaseFile } func (f *File) ErrCount() int { return 2 } func (f *File) Fulfill(ctx context.Context, dispatchErr func(error)) error { - e := newExporter(f.presets, f.flags) + e := newExporter(f.rules, f.flags) if err := e.prepare(); err != nil { return err } -- cgit v1.3.1