container/init: call lockOSThread through dispatcher
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m8s
Test / Hpkg (push) Successful in 4m6s
Test / Sandbox (race detector) (push) Successful in 4m31s
Test / Hakurei (race detector) (push) Successful in 5m5s
Test / Hakurei (push) Successful in 2m8s
Test / Flake checks (push) Successful in 1m20s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m8s
Test / Hpkg (push) Successful in 4m6s
Test / Sandbox (race detector) (push) Successful in 4m31s
Test / Hakurei (race detector) (push) Successful in 5m5s
Test / Hakurei (push) Successful in 2m8s
Test / Flake checks (push) Successful in 1m20s
This degrades test performance if not stubbed out. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
141a18999f
commit
1c692bfb79
@ -8,6 +8,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"hakurei.app/container/seccomp"
|
"hakurei.app/container/seccomp"
|
||||||
@ -21,6 +22,9 @@ type osFile interface {
|
|||||||
|
|
||||||
// syscallDispatcher provides methods that make state-dependent system calls as part of their behaviour.
|
// syscallDispatcher provides methods that make state-dependent system calls as part of their behaviour.
|
||||||
type syscallDispatcher interface {
|
type syscallDispatcher interface {
|
||||||
|
// lockOSThread provides [runtime.LockOSThread].
|
||||||
|
lockOSThread()
|
||||||
|
|
||||||
// setPtracer provides [SetPtracer].
|
// setPtracer provides [SetPtracer].
|
||||||
setPtracer(pid uintptr) error
|
setPtracer(pid uintptr) error
|
||||||
// setDumpable provides [SetDumpable].
|
// setDumpable provides [SetDumpable].
|
||||||
@ -136,6 +140,8 @@ type syscallDispatcher interface {
|
|||||||
// direct implements syscallDispatcher on the current kernel.
|
// direct implements syscallDispatcher on the current kernel.
|
||||||
type direct struct{}
|
type direct struct{}
|
||||||
|
|
||||||
|
func (direct) lockOSThread() { runtime.LockOSThread() }
|
||||||
|
|
||||||
func (direct) setPtracer(pid uintptr) error { return SetPtracer(pid) }
|
func (direct) setPtracer(pid uintptr) error { return SetPtracer(pid) }
|
||||||
func (direct) setDumpable(dumpable uintptr) error { return SetDumpable(dumpable) }
|
func (direct) setDumpable(dumpable uintptr) error { return SetDumpable(dumpable) }
|
||||||
func (direct) setNoNewPrivs() error { return SetNoNewPrivs() }
|
func (direct) setNoNewPrivs() error { return SetNoNewPrivs() }
|
||||||
|
@ -315,6 +315,8 @@ func checkArgReflect(k *kstub, arg string, got any, n int) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (k *kstub) lockOSThread() { k.expect("lockOSThread") }
|
||||||
|
|
||||||
func (k *kstub) setPtracer(pid uintptr) error {
|
func (k *kstub) setPtracer(pid uintptr) error {
|
||||||
return k.expect("setPtracer").error(
|
return k.expect("setPtracer").error(
|
||||||
checkArg(k, "pid", pid, 0))
|
checkArg(k, "pid", pid, 0))
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
. "syscall"
|
. "syscall"
|
||||||
@ -81,11 +80,11 @@ type initParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Init(prepareLogger func(prefix string), setVerbose func(verbose bool)) {
|
func Init(prepareLogger func(prefix string), setVerbose func(verbose bool)) {
|
||||||
initEntrypoint(prepareLogger, setVerbose, direct{})
|
initEntrypoint(direct{}, prepareLogger, setVerbose)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initEntrypoint(prepareLogger func(prefix string), setVerbose func(verbose bool), k syscallDispatcher) {
|
func initEntrypoint(k syscallDispatcher, prepareLogger func(prefix string), setVerbose func(verbose bool)) {
|
||||||
runtime.LockOSThread()
|
k.lockOSThread()
|
||||||
prepareLogger("init")
|
prepareLogger("init")
|
||||||
|
|
||||||
if k.getpid() != 1 {
|
if k.getpid() != 1 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user