aboutsummaryrefslogtreecommitdiffhomepage
path: root/sandbox/container.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-07-01 20:23:33 +0900
committerOphestra <cat@gensokyo.uk>2025-07-01 22:11:32 +0900
commit1a8840bebc673672235b6e10b1b9386f24751757 (patch)
treed1e6772bfd685e2162d047e3640bd3ee55c1a1f7 /sandbox/container.go
parent1fb453dffe4c83866fedfa4590be30ec65e815ff (diff)
sandbox/seccomp: resolve rules natively
This enables loading syscall filter policies from external cross-platform config files. This also removes a significant amount of C code. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'sandbox/container.go')
-rw-r--r--sandbox/container.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/sandbox/container.go b/sandbox/container.go
index 475f6148..efb3e487 100644
--- a/sandbox/container.go
+++ b/sandbox/container.go
@@ -27,20 +27,20 @@ const (
FAllowNet
)
-func (flags HardeningFlags) seccomp(opts seccomp.FilterOpts) seccomp.FilterOpts {
+func (flags HardeningFlags) seccomp(presets seccomp.FilterPreset) seccomp.FilterPreset {
if flags&FSyscallCompat == 0 {
- opts |= seccomp.FilterExt
+ presets |= seccomp.PresetExt
}
if flags&FAllowDevel == 0 {
- opts |= seccomp.FilterDenyDevel
+ presets |= seccomp.PresetDenyDevel
}
if flags&FAllowUserns == 0 {
- opts |= seccomp.FilterDenyNS
+ presets |= seccomp.PresetDenyNS
}
if flags&FAllowTTY == 0 {
- opts |= seccomp.FilterDenyTTY
+ presets |= seccomp.PresetDenyTTY
}
- return opts
+ return presets
}
type (
@@ -94,8 +94,10 @@ type (
Hostname string
// Sequential container setup ops.
*Ops
- // Extra seccomp options.
- Seccomp seccomp.FilterOpts
+ // Extra seccomp flags.
+ SeccompFlags seccomp.PrepareFlag
+ // Extra seccomp presets.
+ SeccompPresets seccomp.FilterPreset
// Permission bits of newly created parent directories.
// The zero value is interpreted as 0755.
ParentPerm os.FileMode
@@ -233,8 +235,8 @@ func (p *Container) Serve() error {
func (p *Container) Wait() error { defer p.cancel(); return p.cmd.Wait() }
func (p *Container) String() string {
- return fmt.Sprintf("argv: %q, flags: %#x, seccomp: %#x",
- p.Args, p.Flags, int(p.Flags.seccomp(p.Seccomp)))
+ return fmt.Sprintf("argv: %q, flags: %#x, seccomp: %#x, presets: %#x",
+ p.Args, p.Flags, int(p.SeccompFlags), int(p.Flags.seccomp(p.SeccompPresets)))
}
func New(ctx context.Context, name string, args ...string) *Container {