aboutsummaryrefslogtreecommitdiffhomepage
path: root/sandbox/seccomp/proc.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-07-02 00:22:27 +0900
committerOphestra <cat@gensokyo.uk>2025-07-02 00:22:27 +0900
commitd5532aade0c3f042c5daa7d1c16e7cce2f4b524a (patch)
treed34166a17ad57439edf1a59d5f54ecc605bd1ba4 /sandbox/seccomp/proc.go
parent0c5409aec7455cbe9e34b0e4d2f0edf0bc3c6e37 (diff)
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 <cat@gensokyo.uk>
Diffstat (limited to 'sandbox/seccomp/proc.go')
-rw-r--r--sandbox/seccomp/proc.go18
1 files changed, 7 insertions, 11 deletions
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
}