diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-21 20:54:03 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-21 20:54:03 +0900 |
| commit | e94acc424c5746eb6cf903ed97b4e71223fda50f (patch) | |
| tree | c55f4b467ed11149006a799421936845bf64de99 /container | |
| parent | b1a4d801be033b41c559e9642ee05e2f0ec43d5b (diff) | |
container/comp: rename from bits
This package will also hold syscall lookup tables for seccomp.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container')
| -rw-r--r-- | container/autoroot_test.go | 32 | ||||
| -rw-r--r-- | container/bits/bits.go | 13 | ||||
| -rw-r--r-- | container/comp/bits.go (renamed from container/bits/seccomp.go) | 14 | ||||
| -rw-r--r-- | container/container.go | 6 | ||||
| -rw-r--r-- | container/container_test.go | 28 | ||||
| -rw-r--r-- | container/init_test.go | 144 | ||||
| -rw-r--r-- | container/initbind.go | 14 | ||||
| -rw-r--r-- | container/initbind_test.go | 22 | ||||
| -rw-r--r-- | container/seccomp/hash_amd64_test.go | 2 | ||||
| -rw-r--r-- | container/seccomp/hash_arm64_test.go | 2 | ||||
| -rw-r--r-- | container/seccomp/hash_test.go | 4 | ||||
| -rw-r--r-- | container/seccomp/libseccomp_test.go | 2 | ||||
| -rw-r--r-- | container/seccomp/presets.go | 26 |
13 files changed, 154 insertions, 155 deletions
diff --git a/container/autoroot_test.go b/container/autoroot_test.go index 129ff4ed..a3889e78 100644 --- a/container/autoroot_test.go +++ b/container/autoroot_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "hakurei.app/container/bits" "hakurei.app/container/check" + "hakurei.app/container/comp" "hakurei.app/container/stub" "hakurei.app/message" ) @@ -23,14 +23,14 @@ func TestAutoRootOp(t *testing.T) { checkOpBehaviour(t, []opBehaviourTestCase{ {"readdir", &Params{ParentPerm: 0750}, &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, }, []stub.Call{ call("readdir", stub.ExpectArgs{"/"}, stubDir(), stub.UniqueError(2)), }, stub.UniqueError(2), nil, nil}, {"early", &Params{ParentPerm: 0750}, &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, }, []stub.Call{ call("readdir", stub.ExpectArgs{"/"}, stubDir("bin", "dev", "etc", "home", "lib64", "lost+found", "mnt", "nix", "proc", "root", "run", "srv", "sys", "tmp", "usr", "var"), nil), @@ -39,7 +39,7 @@ func TestAutoRootOp(t *testing.T) { {"apply", &Params{ParentPerm: 0750}, &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, }, []stub.Call{ call("readdir", stub.ExpectArgs{"/"}, stubDir("bin", "dev", "etc", "home", "lib64", "lost+found", "mnt", "nix", "proc", "root", "run", "srv", "sys", "tmp", "usr", "var"), nil), @@ -60,7 +60,7 @@ func TestAutoRootOp(t *testing.T) { {"success pd", &Params{ParentPerm: 0750}, &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, }, []stub.Call{ call("readdir", stub.ExpectArgs{"/"}, stubDir("bin", "dev", "etc", "home", "lib64", "lost+found", "mnt", "nix", "proc", "root", "run", "srv", "sys", "tmp", "usr", "var"), nil), @@ -127,10 +127,10 @@ func TestAutoRootOp(t *testing.T) { }) checkOpsBuilder(t, []opsBuilderTestCase{ - {"pd", new(Ops).Root(check.MustAbs("/"), bits.BindWritable), Ops{ + {"pd", new(Ops).Root(check.MustAbs("/"), comp.BindWritable), Ops{ &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, }, }}, }) @@ -140,42 +140,42 @@ func TestAutoRootOp(t *testing.T) { {"internal ne", &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, }, &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, resolved: []*BindMountOp{new(BindMountOp)}, }, true}, {"flags differs", &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable | bits.BindDevice, + Flags: comp.BindWritable | comp.BindDevice, }, &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, }, false}, {"host differs", &AutoRootOp{ Host: check.MustAbs("/tmp/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, }, &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, }, false}, {"equals", &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, }, &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, }, true}, }) checkOpMeta(t, []opMetaTestCase{ {"root", &AutoRootOp{ Host: check.MustAbs("/"), - Flags: bits.BindWritable, + Flags: comp.BindWritable, }, "setting up", `auto root "/" flags 0x2`}, }) } diff --git a/container/bits/bits.go b/container/bits/bits.go deleted file mode 100644 index 7aa2e448..00000000 --- a/container/bits/bits.go +++ /dev/null @@ -1,13 +0,0 @@ -// Package bits contains constants for configuring the container. -package bits - -const ( - // BindOptional skips nonexistent host paths. - BindOptional = 1 << iota - // BindWritable mounts filesystem read-write. - BindWritable - // BindDevice allows access to devices (special files) on this filesystem. - BindDevice - // BindEnsure attempts to create the host path if it does not exist. - BindEnsure -) diff --git a/container/bits/seccomp.go b/container/comp/bits.go index 57e3e122..d0993444 100644 --- a/container/bits/seccomp.go +++ b/container/comp/bits.go @@ -1,4 +1,16 @@ -package bits +// Package comp contains constants from container packages without depending on cgo. +package comp + +const ( + // BindOptional skips nonexistent host paths. + BindOptional = 1 << iota + // BindWritable mounts filesystem read-write. + BindWritable + // BindDevice allows access to devices (special files) on this filesystem. + BindDevice + // BindEnsure attempts to create the host path if it does not exist. + BindEnsure +) // FilterPreset specifies parts of the syscall filter preset to enable. type FilterPreset int diff --git a/container/container.go b/container/container.go index ae83fc30..fb031c38 100644 --- a/container/container.go +++ b/container/container.go @@ -14,8 +14,8 @@ import ( . "syscall" "time" - "hakurei.app/container/bits" "hakurei.app/container/check" + "hakurei.app/container/comp" "hakurei.app/container/fhs" "hakurei.app/container/seccomp" "hakurei.app/message" @@ -86,7 +86,7 @@ type ( // Extra seccomp flags. SeccompFlags seccomp.ExportFlag // Seccomp presets. Has no effect unless SeccompRules is zero-length. - SeccompPresets bits.FilterPreset + SeccompPresets comp.FilterPreset // Do not load seccomp program. SeccompDisable bool @@ -174,7 +174,7 @@ func (p *Container) Start() error { } if !p.RetainSession { - p.SeccompPresets |= bits.PresetDenyTTY + p.SeccompPresets |= comp.PresetDenyTTY } if p.AdoptWaitDelay == 0 { diff --git a/container/container_test.go b/container/container_test.go index 11f398bb..b7d0e9d1 100644 --- a/container/container_test.go +++ b/container/container_test.go @@ -20,8 +20,8 @@ import ( "hakurei.app/command" "hakurei.app/container" - "hakurei.app/container/bits" "hakurei.app/container/check" + "hakurei.app/container/comp" "hakurei.app/container/seccomp" "hakurei.app/container/vfs" "hakurei.app/hst" @@ -206,20 +206,20 @@ var containerTestCases = []struct { rules []seccomp.NativeRule flags seccomp.ExportFlag - presets bits.FilterPreset + presets comp.FilterPreset }{ {"minimal", true, false, false, true, emptyOps, emptyMnt, - 1000, 100, nil, 0, bits.PresetStrict}, + 1000, 100, nil, 0, comp.PresetStrict}, {"allow", true, true, true, false, emptyOps, emptyMnt, - 1000, 100, nil, 0, bits.PresetExt | bits.PresetDenyDevel}, + 1000, 100, nil, 0, comp.PresetExt | comp.PresetDenyDevel}, {"no filter", false, true, true, true, emptyOps, emptyMnt, - 1000, 100, nil, 0, bits.PresetExt}, + 1000, 100, nil, 0, comp.PresetExt}, {"custom rules", true, true, true, false, emptyOps, emptyMnt, - 1, 31, []seccomp.NativeRule{{Syscall: seccomp.ScmpSyscall(syscall.SYS_SETUID), Errno: seccomp.ScmpErrno(syscall.EPERM)}}, 0, bits.PresetExt}, + 1, 31, []seccomp.NativeRule{{Syscall: seccomp.ScmpSyscall(syscall.SYS_SETUID), Errno: seccomp.ScmpErrno(syscall.EPERM)}}, 0, comp.PresetExt}, {"tmpfs", true, false, false, true, earlyOps(new(container.Ops). @@ -228,7 +228,7 @@ var containerTestCases = []struct { earlyMnt( ent("/", hst.PrivateTmp, "rw,nosuid,nodev,relatime", "tmpfs", "ephemeral", ignore), ), - 9, 9, nil, 0, bits.PresetStrict}, + 9, 9, nil, 0, comp.PresetStrict}, {"dev", true, true /* go test output is not a tty */, false, false, earlyOps(new(container.Ops). @@ -246,7 +246,7 @@ var containerTestCases = []struct { ent("/", "/dev/mqueue", "rw,nosuid,nodev,noexec,relatime", "mqueue", "mqueue", "rw"), ent("/", "/dev/shm", "rw,nosuid,nodev,relatime", "tmpfs", "tmpfs", ignore), ), - 1971, 100, nil, 0, bits.PresetStrict}, + 1971, 100, nil, 0, comp.PresetStrict}, {"dev no mqueue", true, true /* go test output is not a tty */, false, false, earlyOps(new(container.Ops). @@ -263,7 +263,7 @@ var containerTestCases = []struct { ent("/", "/dev/pts", "rw,nosuid,noexec,relatime", "devpts", "devpts", "rw,mode=620,ptmxmode=666"), ent("/", "/dev/shm", "rw,nosuid,nodev,relatime", "tmpfs", "tmpfs", ignore), ), - 1971, 100, nil, 0, bits.PresetStrict}, + 1971, 100, nil, 0, comp.PresetStrict}, {"overlay", true, false, false, true, func(t *testing.T) (*container.Ops, context.Context) { @@ -300,7 +300,7 @@ var containerTestCases = []struct { ",redirect_dir=nofollow,uuid=on,userxattr"), } }, - 1 << 3, 1 << 14, nil, 0, bits.PresetStrict}, + 1 << 3, 1 << 14, nil, 0, comp.PresetStrict}, {"overlay ephemeral", true, false, false, true, func(t *testing.T) (*container.Ops, context.Context) { @@ -324,7 +324,7 @@ var containerTestCases = []struct { ent("/", hst.PrivateTmp, "rw", "overlay", "overlay", ignore), } }, - 1 << 3, 1 << 14, nil, 0, bits.PresetStrict}, + 1 << 3, 1 << 14, nil, 0, comp.PresetStrict}, {"overlay readonly", true, false, false, true, func(t *testing.T) (*container.Ops, context.Context) { @@ -352,7 +352,7 @@ var containerTestCases = []struct { ",redirect_dir=nofollow,userxattr"), } }, - 1 << 3, 1 << 14, nil, 0, bits.PresetStrict}, + 1 << 3, 1 << 14, nil, 0, comp.PresetStrict}, } func TestContainer(t *testing.T) { @@ -560,9 +560,9 @@ func TestContainerString(t *testing.T) { c := container.NewCommand(t.Context(), msg, check.MustAbs("/run/current-system/sw/bin/ldd"), "ldd", "/usr/bin/env") c.SeccompFlags |= seccomp.AllowMultiarch c.SeccompRules = seccomp.Preset( - bits.PresetExt|bits.PresetDenyNS|bits.PresetDenyTTY, + comp.PresetExt|comp.PresetDenyNS|comp.PresetDenyTTY, c.SeccompFlags) - c.SeccompPresets = bits.PresetStrict + c.SeccompPresets = comp.PresetStrict want := `argv: ["ldd" "/usr/bin/env"], filter: true, rules: 65, flags: 0x1, presets: 0xf` if got := c.String(); got != want { t.Errorf("String: %s, want %s", got, want) diff --git a/container/init_test.go b/container/init_test.go index c0cfcfc6..27f41a4a 100644 --- a/container/init_test.go +++ b/container/init_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "hakurei.app/container/bits" "hakurei.app/container/check" + "hakurei.app/container/comp" "hakurei.app/container/seccomp" "hakurei.app/container/stub" ) @@ -70,7 +70,7 @@ func TestInitEntrypoint(t *testing.T) { Gid: 1 << 31, Hostname: "hakurei-check", SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(79), nil), @@ -95,7 +95,7 @@ func TestInitEntrypoint(t *testing.T) { Hostname: "hakurei-check", Ops: (*Ops)(sliceAddr(make(Ops, 1))), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(78), nil), @@ -123,7 +123,7 @@ func TestInitEntrypoint(t *testing.T) { Hostname: "hakurei-check", Ops: (*Ops)(sliceAddr(make(Ops, 1))), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(76), nil), @@ -152,7 +152,7 @@ func TestInitEntrypoint(t *testing.T) { Hostname: "hakurei-check", Ops: (*Ops)(sliceAddr(make(Ops, 1))), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(74), nil), @@ -182,7 +182,7 @@ func TestInitEntrypoint(t *testing.T) { Hostname: "hakurei-check", Ops: (*Ops)(sliceAddr(make(Ops, 1))), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(72), nil), @@ -213,7 +213,7 @@ func TestInitEntrypoint(t *testing.T) { Hostname: "hakurei-check", Ops: (*Ops)(sliceAddr(make(Ops, 1))), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(70), nil), @@ -245,7 +245,7 @@ func TestInitEntrypoint(t *testing.T) { Hostname: "hakurei-check", Ops: (*Ops)(sliceAddr(make(Ops, 1))), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(68), nil), @@ -279,7 +279,7 @@ func TestInitEntrypoint(t *testing.T) { Hostname: "hakurei-check", Ops: (*Ops)(sliceAddr(make(Ops, 1))), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(66), nil), @@ -315,7 +315,7 @@ func TestInitEntrypoint(t *testing.T) { Hostname: "hakurei-check", Ops: (*Ops)(sliceAddr(make(Ops, 1))), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(64), nil), @@ -351,9 +351,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(nil, nil, bits.BindDevice), + Ops: new(Ops).Bind(nil, nil, comp.BindDevice), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(63), nil), @@ -389,9 +389,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(62), nil), @@ -428,9 +428,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(60), nil), @@ -467,9 +467,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(59), nil), @@ -507,9 +507,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(57), nil), @@ -548,9 +548,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(55), nil), @@ -590,9 +590,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(53), nil), @@ -633,9 +633,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(51), nil), @@ -677,9 +677,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(49), nil), @@ -722,9 +722,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(47), nil), @@ -768,9 +768,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(45), nil), @@ -823,9 +823,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(43), nil), @@ -878,9 +878,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(42), nil), @@ -934,9 +934,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(40), nil), @@ -991,9 +991,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(38), nil), @@ -1050,9 +1050,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(36), nil), @@ -1110,9 +1110,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(34), nil), @@ -1171,9 +1171,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(32), nil), @@ -1233,9 +1233,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(30), nil), @@ -1296,9 +1296,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(28), nil), @@ -1360,9 +1360,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(26), nil), @@ -1425,9 +1425,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(24), nil), @@ -1491,9 +1491,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(22), nil), @@ -1565,9 +1565,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(20), nil), @@ -1672,9 +1672,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(18), nil), @@ -1780,9 +1780,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(16), nil), @@ -1869,7 +1869,7 @@ func TestInitEntrypoint(t *testing.T) { call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x28)}, nil, nil), call("capAmbientRaise", stub.ExpectArgs{uintptr(0x15)}, nil, nil), call("capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, &[2]capData{{0, 0x200000, 0x200000}, {0, 0, 0}}}, nil, nil), - call("verbosef", stub.ExpectArgs{"resolving presets %#x", []any{bits.FilterPreset(0xf)}}, nil, nil), + call("verbosef", stub.ExpectArgs{"resolving presets %#x", []any{comp.FilterPreset(0xf)}}, nil, nil), call("seccompLoad", stub.ExpectArgs{seccomp.Preset(0xf, 0), seccomp.ExportFlag(0)}, nil, stub.UniqueError(15)), call("fatalf", stub.ExpectArgs{"cannot load syscall filter: %v", []any{stub.UniqueError(15)}}, nil, nil), }, @@ -1890,7 +1890,7 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 24, Gid: 1 << 47, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), SeccompDisable: true, ParentPerm: 0750, @@ -2004,7 +2004,7 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 24, Gid: 1 << 47, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), SeccompDisable: true, ParentPerm: 0750, @@ -2106,7 +2106,7 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 24, Gid: 1 << 47, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), SeccompDisable: true, ParentPerm: 0750, @@ -2199,7 +2199,7 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 24, Gid: 1 << 47, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), SeccompDisable: true, ParentPerm: 0750, @@ -2294,7 +2294,7 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 24, Gid: 1 << 47, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), SeccompDisable: true, ParentPerm: 0750, @@ -2396,7 +2396,7 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 24, Gid: 1 << 47, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), SeccompDisable: true, ParentPerm: 0750, @@ -2534,9 +2534,9 @@ func TestInitEntrypoint(t *testing.T) { Uid: 1 << 32, Gid: 1 << 31, Hostname: "hakurei-check", - Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), bits.BindDevice).Proc(check.MustAbs("/proc/")), + Ops: new(Ops).Bind(check.MustAbs("/"), check.MustAbs("/"), comp.BindDevice).Proc(check.MustAbs("/proc/")), SeccompRules: make([]seccomp.NativeRule, 0), - SeccompPresets: bits.PresetStrict, + SeccompPresets: comp.PresetStrict, RetainSession: true, Privileged: true, }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(0), nil), @@ -2623,7 +2623,7 @@ func TestInitEntrypoint(t *testing.T) { call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x28)}, nil, nil), call("capAmbientRaise", stub.ExpectArgs{uintptr(0x15)}, nil, nil), call("capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, &[2]capData{{0, 0x200000, 0x200000}, {0, 0, 0}}}, nil, nil), - call("verbosef", stub.ExpectArgs{"resolving presets %#x", []any{bits.FilterPreset(0xf)}}, nil, nil), + call("verbosef", stub.ExpectArgs{"resolving presets %#x", []any{comp.FilterPreset(0xf)}}, nil, nil), call("seccompLoad", stub.ExpectArgs{seccomp.Preset(0xf, 0), seccomp.ExportFlag(0)}, nil, nil), call("verbosef", stub.ExpectArgs{"%d filter rules loaded", []any{73}}, nil, nil), call("newFile", stub.ExpectArgs{uintptr(10), "extra file 0"}, (*os.File)(nil), nil), diff --git a/container/initbind.go b/container/initbind.go index 54f00120..12ebf994 100644 --- a/container/initbind.go +++ b/container/initbind.go @@ -6,8 +6,8 @@ import ( "os" "syscall" - "hakurei.app/container/bits" "hakurei.app/container/check" + "hakurei.app/container/comp" ) func init() { gob.Register(new(BindMountOp)) } @@ -29,18 +29,18 @@ type BindMountOp struct { func (b *BindMountOp) Valid() bool { return b != nil && b.Source != nil && b.Target != nil && - b.Flags&(bits.BindOptional|bits.BindEnsure) != (bits.BindOptional|bits.BindEnsure) + b.Flags&(comp.BindOptional|comp.BindEnsure) != (comp.BindOptional|comp.BindEnsure) } func (b *BindMountOp) early(_ *setupState, k syscallDispatcher) error { - if b.Flags&bits.BindEnsure != 0 { + if b.Flags&comp.BindEnsure != 0 { if err := k.mkdirAll(b.Source.String(), 0700); err != nil { return err } } if pathname, err := k.evalSymlinks(b.Source.String()); err != nil { - if os.IsNotExist(err) && b.Flags&bits.BindOptional != 0 { + if os.IsNotExist(err) && b.Flags&comp.BindOptional != 0 { // leave sourceFinal as nil return nil } @@ -53,7 +53,7 @@ func (b *BindMountOp) early(_ *setupState, k syscallDispatcher) error { func (b *BindMountOp) apply(state *setupState, k syscallDispatcher) error { if b.sourceFinal == nil { - if b.Flags&bits.BindOptional == 0 { + if b.Flags&comp.BindOptional == 0 { // unreachable return OpStateError("bind") } @@ -76,10 +76,10 @@ func (b *BindMountOp) apply(state *setupState, k syscallDispatcher) error { } var flags uintptr = syscall.MS_REC - if b.Flags&bits.BindWritable == 0 { + if b.Flags&comp.BindWritable == 0 { flags |= syscall.MS_RDONLY } - if b.Flags&bits.BindDevice == 0 { + if b.Flags&comp.BindDevice == 0 { flags |= syscall.MS_NODEV } diff --git a/container/initbind_test.go b/container/initbind_test.go index 323a0328..86ab1f9c 100644 --- a/container/initbind_test.go +++ b/container/initbind_test.go @@ -6,8 +6,8 @@ import ( "syscall" "testing" - "hakurei.app/container/bits" "hakurei.app/container/check" + "hakurei.app/container/comp" "hakurei.app/container/stub" ) @@ -25,7 +25,7 @@ func TestBindMountOp(t *testing.T) { {"skip optional", new(Params), &BindMountOp{ Source: check.MustAbs("/bin/"), Target: check.MustAbs("/bin/"), - Flags: bits.BindOptional, + Flags: comp.BindOptional, }, []stub.Call{ call("evalSymlinks", stub.ExpectArgs{"/bin/"}, "", syscall.ENOENT), }, nil, nil, nil}, @@ -33,7 +33,7 @@ func TestBindMountOp(t *testing.T) { {"success optional", new(Params), &BindMountOp{ Source: check.MustAbs("/bin/"), Target: check.MustAbs("/bin/"), - Flags: bits.BindOptional, + Flags: comp.BindOptional, }, []stub.Call{ call("evalSymlinks", stub.ExpectArgs{"/bin/"}, "/usr/bin", nil), }, nil, []stub.Call{ @@ -46,7 +46,7 @@ func TestBindMountOp(t *testing.T) { {"ensureFile device", new(Params), &BindMountOp{ Source: check.MustAbs("/dev/null"), Target: check.MustAbs("/dev/null"), - Flags: bits.BindWritable | bits.BindDevice, + Flags: comp.BindWritable | comp.BindDevice, }, []stub.Call{ call("evalSymlinks", stub.ExpectArgs{"/dev/null"}, "/dev/null", nil), }, nil, []stub.Call{ @@ -57,7 +57,7 @@ func TestBindMountOp(t *testing.T) { {"mkdirAll ensure", new(Params), &BindMountOp{ Source: check.MustAbs("/bin/"), Target: check.MustAbs("/bin/"), - Flags: bits.BindEnsure, + Flags: comp.BindEnsure, }, []stub.Call{ call("mkdirAll", stub.ExpectArgs{"/bin/", os.FileMode(0700)}, nil, stub.UniqueError(4)), }, stub.UniqueError(4), nil, nil}, @@ -65,7 +65,7 @@ func TestBindMountOp(t *testing.T) { {"success ensure", new(Params), &BindMountOp{ Source: check.MustAbs("/bin/"), Target: check.MustAbs("/usr/bin/"), - Flags: bits.BindEnsure, + Flags: comp.BindEnsure, }, []stub.Call{ call("mkdirAll", stub.ExpectArgs{"/bin/", os.FileMode(0700)}, nil, nil), call("evalSymlinks", stub.ExpectArgs{"/bin/"}, "/usr/bin", nil), @@ -79,7 +79,7 @@ func TestBindMountOp(t *testing.T) { {"success device ro", new(Params), &BindMountOp{ Source: check.MustAbs("/dev/null"), Target: check.MustAbs("/dev/null"), - Flags: bits.BindDevice, + Flags: comp.BindDevice, }, []stub.Call{ call("evalSymlinks", stub.ExpectArgs{"/dev/null"}, "/dev/null", nil), }, nil, []stub.Call{ @@ -92,7 +92,7 @@ func TestBindMountOp(t *testing.T) { {"success device", new(Params), &BindMountOp{ Source: check.MustAbs("/dev/null"), Target: check.MustAbs("/dev/null"), - Flags: bits.BindWritable | bits.BindDevice, + Flags: comp.BindWritable | comp.BindDevice, }, []stub.Call{ call("evalSymlinks", stub.ExpectArgs{"/dev/null"}, "/dev/null", nil), }, nil, []stub.Call{ @@ -182,7 +182,7 @@ func TestBindMountOp(t *testing.T) { {"zero", new(BindMountOp), false}, {"nil source", &BindMountOp{Target: check.MustAbs("/")}, false}, {"nil target", &BindMountOp{Source: check.MustAbs("/")}, false}, - {"flag optional ensure", &BindMountOp{Source: check.MustAbs("/"), Target: check.MustAbs("/"), Flags: bits.BindOptional | bits.BindEnsure}, false}, + {"flag optional ensure", &BindMountOp{Source: check.MustAbs("/"), Target: check.MustAbs("/"), Flags: comp.BindOptional | comp.BindEnsure}, false}, {"valid", &BindMountOp{Source: check.MustAbs("/"), Target: check.MustAbs("/")}, true}, }) @@ -217,7 +217,7 @@ func TestBindMountOp(t *testing.T) { }, &BindMountOp{ Source: check.MustAbs("/etc/"), Target: check.MustAbs("/etc/.host/048090b6ed8f9ebb10e275ff5d8c0659"), - Flags: bits.BindOptional, + Flags: comp.BindOptional, }, false}, {"source differs", &BindMountOp{ @@ -256,7 +256,7 @@ func TestBindMountOp(t *testing.T) { {"hostdev", &BindMountOp{ Source: check.MustAbs("/dev/"), Target: check.MustAbs("/dev/"), - Flags: bits.BindWritable | bits.BindDevice, + Flags: comp.BindWritable | comp.BindDevice, }, "mounting", `"/dev/" flags 0x6`}, }) } diff --git a/container/seccomp/hash_amd64_test.go b/container/seccomp/hash_amd64_test.go index 5a5e5439..eb3e6092 100644 --- a/container/seccomp/hash_amd64_test.go +++ b/container/seccomp/hash_amd64_test.go @@ -1,7 +1,7 @@ package seccomp_test import ( - . "hakurei.app/container/bits" + . "hakurei.app/container/comp" . "hakurei.app/container/seccomp" ) diff --git a/container/seccomp/hash_arm64_test.go b/container/seccomp/hash_arm64_test.go index 2395bcee..44c692d5 100644 --- a/container/seccomp/hash_arm64_test.go +++ b/container/seccomp/hash_arm64_test.go @@ -1,7 +1,7 @@ package seccomp_test import ( - . "hakurei.app/container/bits" + . "hakurei.app/container/comp" . "hakurei.app/container/seccomp" ) diff --git a/container/seccomp/hash_test.go b/container/seccomp/hash_test.go index 5c995582..90bfe638 100644 --- a/container/seccomp/hash_test.go +++ b/container/seccomp/hash_test.go @@ -4,14 +4,14 @@ import ( "crypto/sha512" "encoding/hex" - "hakurei.app/container/bits" + "hakurei.app/container/comp" "hakurei.app/container/seccomp" ) type ( bpfPreset = struct { seccomp.ExportFlag - bits.FilterPreset + comp.FilterPreset } bpfLookup map[bpfPreset][sha512.Size]byte ) diff --git a/container/seccomp/libseccomp_test.go b/container/seccomp/libseccomp_test.go index 5d58ac7a..cb5a29cb 100644 --- a/container/seccomp/libseccomp_test.go +++ b/container/seccomp/libseccomp_test.go @@ -6,7 +6,7 @@ import ( "syscall" "testing" - . "hakurei.app/container/bits" + . "hakurei.app/container/comp" . "hakurei.app/container/seccomp" ) diff --git a/container/seccomp/presets.go b/container/seccomp/presets.go index f12d9f76..1f6f7290 100644 --- a/container/seccomp/presets.go +++ b/container/seccomp/presets.go @@ -5,32 +5,32 @@ package seccomp import ( . "syscall" - "hakurei.app/container/bits" + "hakurei.app/container/comp" ) -func Preset(presets bits.FilterPreset, flags ExportFlag) (rules []NativeRule) { +func Preset(presets comp.FilterPreset, flags ExportFlag) (rules []NativeRule) { allowedPersonality := PersonaLinux - if presets&bits.PresetLinux32 != 0 { + if presets&comp.PresetLinux32 != 0 { allowedPersonality = PersonaLinux32 } presetDevelFinal := presetDevel(ScmpDatum(allowedPersonality)) l := len(presetCommon) - if presets&bits.PresetDenyNS != 0 { + if presets&comp.PresetDenyNS != 0 { l += len(presetNamespace) } - if presets&bits.PresetDenyTTY != 0 { + if presets&comp.PresetDenyTTY != 0 { l += len(presetTTY) } - if presets&bits.PresetDenyDevel != 0 { + if presets&comp.PresetDenyDevel != 0 { l += len(presetDevelFinal) } if flags&AllowMultiarch == 0 { l += len(presetEmu) } - if presets&bits.PresetExt != 0 { + if presets&comp.PresetExt != 0 { l += len(presetCommonExt) - if presets&bits.PresetDenyNS != 0 { + if presets&comp.PresetDenyNS != 0 { l += len(presetNamespaceExt) } if flags&AllowMultiarch == 0 { @@ -40,21 +40,21 @@ func Preset(presets bits.FilterPreset, flags ExportFlag) (rules []NativeRule) { rules = make([]NativeRule, 0, l) rules = append(rules, presetCommon...) - if presets&bits.PresetDenyNS != 0 { + if presets&comp.PresetDenyNS != 0 { rules = append(rules, presetNamespace...) } - if presets&bits.PresetDenyTTY != 0 { + if presets&comp.PresetDenyTTY != 0 { rules = append(rules, presetTTY...) } - if presets&bits.PresetDenyDevel != 0 { + if presets&comp.PresetDenyDevel != 0 { rules = append(rules, presetDevelFinal...) } if flags&AllowMultiarch == 0 { rules = append(rules, presetEmu...) } - if presets&bits.PresetExt != 0 { + if presets&comp.PresetExt != 0 { rules = append(rules, presetCommonExt...) - if presets&bits.PresetDenyNS != 0 { + if presets&comp.PresetDenyNS != 0 { rules = append(rules, presetNamespaceExt...) } if flags&AllowMultiarch == 0 { |
