diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-13 18:49:58 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-13 18:51:35 +0900 |
| commit | 123d7fbfd5a2955dc5042c0a85211e376d5a8e65 (patch) | |
| tree | 7e03e35309083b81873f3cf1939d2f4d27d41659 /container/seccomp/proc.go | |
| parent | 7638a44fa613f23434318bdf136723aa010e8638 (diff) | |
container/seccomp: remove export pipe
This was only useful when wrapping bwrap.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/seccomp/proc.go')
| -rw-r--r-- | container/seccomp/proc.go | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/container/seccomp/proc.go b/container/seccomp/proc.go deleted file mode 100644 index fb6f5430..00000000 --- a/container/seccomp/proc.go +++ /dev/null @@ -1,72 +0,0 @@ -package seccomp - -import ( - "context" - "errors" - "syscall" - - "hakurei.app/helper/proc" -) - -// New returns an inactive Encoder instance. -func New(rules []NativeRule, flags ExportFlag) *Encoder { return &Encoder{newExporter(rules, flags)} } - -// Load loads a filter into the kernel. -func Load(rules []NativeRule, flags ExportFlag) error { return Export(-1, rules, flags) } - -/* -An Encoder writes a BPF program to an output stream. - -Methods of Encoder are not safe for concurrent use. - -An Encoder must not be copied after first use. -*/ -type Encoder struct{ *exporter } - -func (e *Encoder) Read(p []byte) (n int, err error) { - if err = e.prepare(); err != nil { - return - } - return e.r.Read(p) -} - -func (e *Encoder) Close() error { - if e.r == nil { - return syscall.EINVAL - } - - // this hangs if the cgo thread fails to exit - return errors.Join(e.closeWrite(), <-e.exportErr) -} - -// NewFile returns an instance of exporter implementing [proc.File]. -func NewFile(rules []NativeRule, flags ExportFlag) 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 { - rules []NativeRule - flags ExportFlag - proc.BaseFile -} - -func (f *File) ErrCount() int { return 2 } -func (f *File) Fulfill(ctx context.Context, dispatchErr func(error)) error { - e := newExporter(f.rules, f.flags) - if err := e.prepare(); err != nil { - return err - } - f.Set(e.r) - go func() { - select { - case err := <-e.exportErr: - dispatchErr(nil) - dispatchErr(err) - case <-ctx.Done(): - dispatchErr(e.closeWrite()) - dispatchErr(<-e.exportErr) - } - }() - return nil -} |
