diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-09-02 04:44:08 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-09-02 04:44:08 +0900 |
| commit | 1b5d20a39b2c5720d83a8eaf3d2227deb46a7c0d (patch) | |
| tree | 230a5de997b6a7216f697a06f8f18bd552d96e77 /container/init_test.go | |
| parent | 49600a6f46d99ff35d883381670548de1f01846e (diff) | |
container/dispatcher: stub.Call initialisation helper function
This keeps composites analysis happy without making the test cases (too) bloated.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/init_test.go')
| -rw-r--r-- | container/init_test.go | 3272 |
1 files changed, 1636 insertions, 1636 deletions
diff --git a/container/init_test.go b/container/init_test.go index e6a7511d..99e2976c 100644 --- a/container/init_test.go +++ b/container/init_test.go @@ -31,48 +31,48 @@ func TestInitEntrypoint(t *testing.T) { checkSimple(t, "initEntrypoint", []simpleTestCase{ {"getpid", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1 << 10, nil}, - {"fatal", stub.ExpectArgs{[]any{"this process must run as pid 1"}}, nil, nil}, + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1<<10, nil), + call("fatal", stub.ExpectArgs{[]any{"this process must run as pid 1"}}, nil, nil), }, }, nil}, {"receive bad fd", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr)}, nil, syscall.EBADF}, - {"fatal", stub.ExpectArgs{[]any{"invalid setup descriptor"}}, nil, nil}, + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr)}, nil, syscall.EBADF), + call("fatal", stub.ExpectArgs{[]any{"invalid setup descriptor"}}, nil, nil), }, }, nil}, {"receive not set", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr)}, nil, ErrReceiveEnv}, - {"fatal", stub.ExpectArgs{[]any{"HAKUREI_SETUP not set"}}, nil, nil}, + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr)}, nil, ErrReceiveEnv), + call("fatal", stub.ExpectArgs{[]any{"HAKUREI_SETUP not set"}}, nil, nil), }, }, nil}, {"receive payload decode", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr)}, nil, stub.UniqueError(80)}, - {"fatalf", stub.ExpectArgs{"cannot decode init setup payload: %v", []any{stub.UniqueError(80)}}, nil, nil}, + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr)}, nil, stub.UniqueError(80)), + call("fatalf", stub.ExpectArgs{"cannot decode init setup payload: %v", []any{stub.UniqueError(80)}}, nil, nil), }, }, nil}, {"receive invalid params", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -86,17 +86,17 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(79), nil}, - {"fatal", stub.ExpectArgs{[]any{"invalid setup parameters"}}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(79), nil), + call("fatal", stub.ExpectArgs{[]any{"invalid setup parameters"}}, nil, nil), }, }, nil}, {"setDumpable user", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -111,19 +111,19 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(78), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, stub.UniqueError(77)}, - {"fatalf", stub.ExpectArgs{"cannot set SUID_DUMP_USER: %v", []any{stub.UniqueError(77)}}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(78), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, stub.UniqueError(77)), + call("fatalf", stub.ExpectArgs{"cannot set SUID_DUMP_USER: %v", []any{stub.UniqueError(77)}}, nil, nil), }, }, nil}, {"writeFile uid_map", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -138,20 +138,20 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(76), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, stub.UniqueError(75)}, - {"fatalf", stub.ExpectArgs{"%v", []any{stub.UniqueError(75)}}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(76), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, stub.UniqueError(75)), + call("fatalf", stub.ExpectArgs{"%v", []any{stub.UniqueError(75)}}, nil, nil), }, }, nil}, {"writeFile setgroups", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -166,21 +166,21 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(74), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, stub.UniqueError(73)}, - {"fatalf", stub.ExpectArgs{"%v", []any{stub.UniqueError(73)}}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(74), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, stub.UniqueError(73)), + call("fatalf", stub.ExpectArgs{"%v", []any{stub.UniqueError(73)}}, nil, nil), }, }, nil}, {"writeFile gid_map", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -195,22 +195,22 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(72), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, stub.UniqueError(71)}, - {"fatalf", stub.ExpectArgs{"%v", []any{stub.UniqueError(71)}}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(72), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, stub.UniqueError(71)), + call("fatalf", stub.ExpectArgs{"%v", []any{stub.UniqueError(71)}}, nil, nil), }, }, nil}, {"setDumpable disable", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -225,23 +225,23 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(70), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, stub.UniqueError(69)}, - {"fatalf", stub.ExpectArgs{"cannot set SUID_DUMP_DISABLE: %v", []any{stub.UniqueError(69)}}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(70), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, stub.UniqueError(69)), + call("fatalf", stub.ExpectArgs{"cannot set SUID_DUMP_DISABLE: %v", []any{stub.UniqueError(69)}}, nil, nil), }, }, nil}, {"sethostname", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -256,25 +256,25 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(68), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, stub.UniqueError(67)}, - {"fatalf", stub.ExpectArgs{"cannot set hostname: %v", []any{stub.UniqueError(67)}}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(68), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, stub.UniqueError(67)), + call("fatalf", stub.ExpectArgs{"cannot set hostname: %v", []any{stub.UniqueError(67)}}, nil, nil), }, }, nil}, {"mount rslave root", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -289,27 +289,27 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(66), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, stub.UniqueError(65)}, - {"fatalf", stub.ExpectArgs{"cannot make / rslave: %v", []any{stub.UniqueError(65)}}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(66), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, stub.UniqueError(65)), + call("fatalf", stub.ExpectArgs{"cannot make / rslave: %v", []any{stub.UniqueError(65)}}, nil, nil), }, }, nil}, {"nil op", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -324,29 +324,29 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(64), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(64), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"fatalf", stub.ExpectArgs{"invalid op at index %d", []any{0}}, nil, nil}, + call("fatalf", stub.ExpectArgs{"invalid op at index %d", []any{0}}, nil, nil), /* end early */ }, }, nil}, {"invalid op", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -361,29 +361,29 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(63), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(63), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"fatalf", stub.ExpectArgs{"invalid op at index %d", []any{0}}, nil, nil}, + call("fatalf", stub.ExpectArgs{"invalid op at index %d", []any{0}}, nil, nil), /* end early */ }, }, nil}, {"early unhandled error", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -398,30 +398,30 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(62), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(62), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", stub.UniqueError(61)}, - {"fatalf", stub.ExpectArgs{"cannot prepare op at index %d: %v", []any{0, stub.UniqueError(61)}}, nil, nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", stub.UniqueError(61)), + call("fatalf", stub.ExpectArgs{"cannot prepare op at index %d: %v", []any{0, stub.UniqueError(61)}}, nil, nil), /* end early */ }, }, nil}, {"early", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -436,30 +436,30 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(60), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(60), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", &os.PathError{Op: "readlink", Path: "/", Err: stub.UniqueError(60)}}, - {"fatal", stub.ExpectArgs{[]any{"cannot readlink /: unique error 60 injected by the test suite"}}, nil, nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", &os.PathError{Op: "readlink", Path: "/", Err: stub.UniqueError(60)}), + call("fatal", stub.ExpectArgs{[]any{"cannot readlink /: unique error 60 injected by the test suite"}}, nil, nil), /* end early */ }, }, nil}, {"mount ih", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -474,31 +474,31 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(59), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(59), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, stub.UniqueError(58)}, - {"fatalf", stub.ExpectArgs{"cannot mount intermediate root: %v", []any{stub.UniqueError(58)}}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, stub.UniqueError(58)), + call("fatalf", stub.ExpectArgs{"cannot mount intermediate root: %v", []any{stub.UniqueError(58)}}, nil, nil), }, }, nil}, {"chdir ih", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -513,32 +513,32 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(57), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(57), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, stub.UniqueError(56)}, - {"fatalf", stub.ExpectArgs{"cannot enter intermediate host path: %v", []any{stub.UniqueError(56)}}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, stub.UniqueError(56)), + call("fatalf", stub.ExpectArgs{"cannot enter intermediate host path: %v", []any{stub.UniqueError(56)}}, nil, nil), }, }, nil}, {"mkdir sysroot", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -553,33 +553,33 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(55), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(55), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, stub.UniqueError(54)}, - {"fatalf", stub.ExpectArgs{"%v", []any{stub.UniqueError(54)}}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, stub.UniqueError(54)), + call("fatalf", stub.ExpectArgs{"%v", []any{stub.UniqueError(54)}}, nil, nil), }, }, nil}, {"mount bind sysroot", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -594,34 +594,34 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(53), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(53), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, stub.UniqueError(52)}, - {"fatalf", stub.ExpectArgs{"cannot bind sysroot: %v", []any{stub.UniqueError(52)}}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, stub.UniqueError(52)), + call("fatalf", stub.ExpectArgs{"cannot bind sysroot: %v", []any{stub.UniqueError(52)}}, nil, nil), }, }, nil}, {"mkdir host", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -636,35 +636,35 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(51), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(51), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, stub.UniqueError(50)}, - {"fatalf", stub.ExpectArgs{"%v", []any{stub.UniqueError(50)}}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, stub.UniqueError(50)), + call("fatalf", stub.ExpectArgs{"%v", []any{stub.UniqueError(50)}}, nil, nil), }, }, nil}, {"pivotRoot ir", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -679,36 +679,36 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(49), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(49), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, stub.UniqueError(48)}, - {"fatalf", stub.ExpectArgs{"cannot pivot into intermediate root: %v", []any{stub.UniqueError(48)}}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, stub.UniqueError(48)), + call("fatalf", stub.ExpectArgs{"cannot pivot into intermediate root: %v", []any{stub.UniqueError(48)}}, nil, nil), }, }, nil}, {"chdir ir", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -723,37 +723,37 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(47), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(47), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, stub.UniqueError(46)}, - {"fatalf", stub.ExpectArgs{"cannot enter intermediate root: %v", []any{stub.UniqueError(46)}}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, stub.UniqueError(46)), + call("fatalf", stub.ExpectArgs{"cannot enter intermediate root: %v", []any{stub.UniqueError(46)}}, nil, nil), }, }, nil}, {"apply unhandled error", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -768,46 +768,46 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(45), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(45), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, stub.UniqueError(44)}, - {"fatalf", stub.ExpectArgs{"cannot apply op at index %d: %v", []any{1, stub.UniqueError(44)}}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, stub.UniqueError(44)), + call("fatalf", stub.ExpectArgs{"cannot apply op at index %d: %v", []any{1, stub.UniqueError(44)}}, nil, nil), /* end apply */ }, }, nil}, {"apply", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -822,46 +822,46 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(43), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(43), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, &MountError{"proc", "/sysroot/proc", "proc", uintptr(0xe), "", syscall.ENOTRECOVERABLE}}, - {"fatal", stub.ExpectArgs{[]any{"cannot mount proc on /sysroot/proc: state not recoverable"}}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, &MountError{"proc", "/sysroot/proc", "proc", uintptr(0xe), "", syscall.ENOTRECOVERABLE}), + call("fatal", stub.ExpectArgs{[]any{"cannot mount proc on /sysroot/proc: state not recoverable"}}, nil, nil), /* end apply */ }, }, nil}, {"mount rprivate host", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -876,47 +876,47 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(42), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(42), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, stub.UniqueError(41)}, - {"fatalf", stub.ExpectArgs{"cannot make host root rprivate: %v", []any{stub.UniqueError(41)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, stub.UniqueError(41)), + call("fatalf", stub.ExpectArgs{"cannot make host root rprivate: %v", []any{stub.UniqueError(41)}}, nil, nil), }, }, nil}, {"unmount host", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -931,48 +931,48 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(40), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(40), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, stub.UniqueError(39)}, - {"fatalf", stub.ExpectArgs{"cannot unmount host root: %v", []any{stub.UniqueError(39)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, stub.UniqueError(39)), + call("fatalf", stub.ExpectArgs{"cannot unmount host root: %v", []any{stub.UniqueError(39)}}, nil, nil), }, }, nil}, {"open ir", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -987,50 +987,50 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(38), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(38), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, stub.UniqueError(37)}, - {"fatalf", stub.ExpectArgs{"cannot open intermediate root: %v", []any{stub.UniqueError(37)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, stub.UniqueError(37)), + call("fatalf", stub.ExpectArgs{"cannot open intermediate root: %v", []any{stub.UniqueError(37)}}, nil, nil), }, }, nil}, {"chdir sysroot", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -1045,51 +1045,51 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(36), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(36), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, stub.UniqueError(35)}, - {"fatalf", stub.ExpectArgs{"cannot enter sysroot: %v", []any{stub.UniqueError(35)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, stub.UniqueError(35)), + call("fatalf", stub.ExpectArgs{"cannot enter sysroot: %v", []any{stub.UniqueError(35)}}, nil, nil), }, }, nil}, {"pivotRoot sysroot", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -1104,52 +1104,52 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(34), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(34), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, stub.UniqueError(33)}, - {"fatalf", stub.ExpectArgs{"cannot pivot into sysroot: %v", []any{stub.UniqueError(33)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, stub.UniqueError(33)), + call("fatalf", stub.ExpectArgs{"cannot pivot into sysroot: %v", []any{stub.UniqueError(33)}}, nil, nil), }, }, nil}, {"fchdir ir", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -1164,53 +1164,53 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(32), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(32), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, stub.UniqueError(31)}, - {"fatalf", stub.ExpectArgs{"cannot re-enter intermediate root: %v", []any{stub.UniqueError(31)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, stub.UniqueError(31)), + call("fatalf", stub.ExpectArgs{"cannot re-enter intermediate root: %v", []any{stub.UniqueError(31)}}, nil, nil), }, }, nil}, {"unmount ir", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -1225,54 +1225,54 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(30), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(30), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, stub.UniqueError(29)}, - {"fatalf", stub.ExpectArgs{"cannot unmount intermediate root: %v", []any{stub.UniqueError(29)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, stub.UniqueError(29)), + call("fatalf", stub.ExpectArgs{"cannot unmount intermediate root: %v", []any{stub.UniqueError(29)}}, nil, nil), }, }, nil}, {"chdir ir", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -1287,55 +1287,55 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(28), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(28), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, stub.UniqueError(27)}, - {"fatalf", stub.ExpectArgs{"cannot enter root: %v", []any{stub.UniqueError(27)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, stub.UniqueError(27)), + call("fatalf", stub.ExpectArgs{"cannot enter root: %v", []any{stub.UniqueError(27)}}, nil, nil), }, }, nil}, {"close ir", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -1350,56 +1350,56 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(26), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(26), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, stub.UniqueError(25)}, - {"fatalf", stub.ExpectArgs{"cannot close intermediate root: %v", []any{stub.UniqueError(25)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, stub.UniqueError(25)), + call("fatalf", stub.ExpectArgs{"cannot close intermediate root: %v", []any{stub.UniqueError(25)}}, nil, nil), }, }, nil}, {"capAmbientClearAll", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -1414,57 +1414,57 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(24), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(24), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, nil}, - {"capAmbientClearAll", stub.ExpectArgs{}, nil, stub.UniqueError(23)}, - {"fatalf", stub.ExpectArgs{"cannot clear the ambient capability set: %v", []any{stub.UniqueError(23)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, nil), + call("capAmbientClearAll", stub.ExpectArgs{}, nil, stub.UniqueError(23)), + call("fatalf", stub.ExpectArgs{"cannot clear the ambient capability set: %v", []any{stub.UniqueError(23)}}, nil, nil), }, }, nil}, {"capBoundingSetDrop", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -1479,65 +1479,65 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(22), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(22), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, nil}, - {"capAmbientClearAll", stub.ExpectArgs{}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, stub.UniqueError(21)}, - {"fatalf", stub.ExpectArgs{"cannot drop capability from bounding set: %v", []any{stub.UniqueError(21)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, nil), + call("capAmbientClearAll", stub.ExpectArgs{}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, stub.UniqueError(21)), + call("fatalf", stub.ExpectArgs{"cannot drop capability from bounding set: %v", []any{stub.UniqueError(21)}}, nil, nil), }, }, nil}, {"capAmbientRaise", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -1552,98 +1552,98 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(20), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(20), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, nil}, - {"capAmbientClearAll", stub.ExpectArgs{}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x8)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x9)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xa)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xb)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xc)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xd)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xe)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xf)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x10)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x11)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x12)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x13)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x14)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x16)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x17)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x18)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x19)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1a)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1b)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1c)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1d)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1e)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1f)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x20)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x21)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x22)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x23)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x24)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x25)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x26)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x27)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x28)}, nil, nil}, - {"capAmbientRaise", stub.ExpectArgs{uintptr(0x15)}, nil, stub.UniqueError(19)}, - {"fatalf", stub.ExpectArgs{"cannot raise CAP_SYS_ADMIN: %v", []any{stub.UniqueError(19)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, nil), + call("capAmbientClearAll", stub.ExpectArgs{}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x8)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x9)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xa)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xb)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xc)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xd)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xe)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xf)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x10)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x11)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x12)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x13)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x14)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x16)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x17)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x18)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x19)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1a)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1b)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1c)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1d)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1e)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1f)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x20)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x21)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x22)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x23)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x24)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x25)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x26)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x27)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x28)}, nil, nil), + call("capAmbientRaise", stub.ExpectArgs{uintptr(0x15)}, nil, stub.UniqueError(19)), + call("fatalf", stub.ExpectArgs{"cannot raise CAP_SYS_ADMIN: %v", []any{stub.UniqueError(19)}}, nil, nil), }, }, nil}, {"capset", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -1658,99 +1658,99 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(18), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(18), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, nil}, - {"capAmbientClearAll", stub.ExpectArgs{}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x8)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x9)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xa)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xb)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xc)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xd)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xe)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xf)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x10)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x11)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x12)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x13)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x14)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x16)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x17)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x18)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x19)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1a)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1b)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1c)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1d)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1e)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1f)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x20)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x21)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x22)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x23)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x24)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x25)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x26)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x27)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x28)}, nil, nil}, - {"capAmbientRaise", stub.ExpectArgs{uintptr(0x15)}, nil, nil}, - {"capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, &[2]capData{{0, 0x200000, 0x200000}, {0, 0, 0}}}, nil, stub.UniqueError(17)}, - {"fatalf", stub.ExpectArgs{"cannot capset: %v", []any{stub.UniqueError(17)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, nil), + call("capAmbientClearAll", stub.ExpectArgs{}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x8)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x9)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xa)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xb)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xc)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xd)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xe)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xf)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x10)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x11)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x12)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x13)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x14)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x16)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x17)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x18)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x19)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1a)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1b)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1c)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1d)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1e)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1f)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x20)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x21)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x22)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x23)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x24)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x25)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x26)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x27)}, nil, nil), + 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, stub.UniqueError(17)), + call("fatalf", stub.ExpectArgs{"cannot capset: %v", []any{stub.UniqueError(17)}}, nil, nil), }, }, nil}, {"seccompLoad", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -1765,102 +1765,102 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(16), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(16), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, nil}, - {"capAmbientClearAll", stub.ExpectArgs{}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x8)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x9)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xa)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xb)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xc)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xd)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xe)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xf)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x10)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x11)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x12)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x13)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x14)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x16)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x17)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x18)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x19)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1a)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1b)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1c)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1d)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1e)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1f)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x20)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x21)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x22)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x23)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x24)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x25)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x26)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x27)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x28)}, nil, nil}, - {"capAmbientRaise", stub.ExpectArgs{uintptr(0x15)}, nil, nil}, - {"capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, &[2]capData{{0, 0x200000, 0x200000}, {0, 0, 0}}}, nil, nil}, - {"verbosef", stub.ExpectArgs{"resolving presets %#x", []any{seccomp.FilterPreset(0xf)}}, nil, nil}, - {"seccompLoad", stub.ExpectArgs{seccomp.Preset(0xf, 0), seccomp.ExportFlag(0)}, nil, stub.UniqueError(15)}, - {"fatalf", stub.ExpectArgs{"cannot load syscall filter: %v", []any{stub.UniqueError(15)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, nil), + call("capAmbientClearAll", stub.ExpectArgs{}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x8)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x9)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xa)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xb)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xc)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xd)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xe)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xf)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x10)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x11)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x12)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x13)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x14)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x16)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x17)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x18)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x19)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1a)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1b)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1c)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1d)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1e)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1f)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x20)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x21)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x22)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x23)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x24)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x25)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x26)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x27)}, nil, nil), + 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{seccomp.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), }, }, nil}, {"start", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseFalse); return nil }, stub.Expect{ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, 0, stub.UniqueError(14)}, - {"verbosef", stub.ExpectArgs{"cannot enable ptrace protection via Yama LSM: %v", []any{stub.UniqueError(14)}}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, 0, stub.UniqueError(14)), + call("verbosef", stub.ExpectArgs{"cannot enable ptrace protection via Yama LSM: %v", []any{stub.UniqueError(14)}}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei/nonexistent"), Path: MustAbs("/run/current-system/sw/bin/bash"), Args: []string{"bash", "-c", "false"}, @@ -1873,107 +1873,107 @@ func TestInitEntrypoint(t *testing.T) { SeccompRules: make([]seccomp.NativeRule, 0), SeccompDisable: true, ParentPerm: 0750, - }, 1971, 127, 2, false}, uintptr(0x39)}, stub.UniqueError(13), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("16777216 1971 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("140737488355328 127 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1971, 127, 2, false}, uintptr(0x39)}, stub.UniqueError(13), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("16777216 1971 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("140737488355328 127 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0750)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0750)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, nil}, - {"capAmbientClearAll", stub.ExpectArgs{}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x8)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x9)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xa)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xb)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xc)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xd)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xe)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xf)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x10)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x11)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x12)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x13)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x14)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x15)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x16)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x17)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x18)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x19)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1a)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1b)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1c)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1d)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1e)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1f)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x20)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x21)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x22)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x23)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x24)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x25)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x26)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x27)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x28)}, nil, nil}, - {"capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, new([2]capData)}, nil, nil}, - {"verbose", stub.ExpectArgs{[]any{"syscall filter not configured"}}, nil, nil}, - {"newFile", stub.ExpectArgs{uintptr(0x3a), "extra file 0"}, (*os.File)(nil), nil}, - {"newFile", stub.ExpectArgs{uintptr(0x3b), "extra file 1"}, (*os.File)(nil), nil}, - {"umask", stub.ExpectArgs{022}, 0, nil}, - {"verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/run/current-system/sw/bin/bash")}}, nil, nil}, - {"start", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent"}, nil, stub.UniqueError(12)}, - {"fatalf", stub.ExpectArgs{"%v", []any{stub.UniqueError(12)}}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, nil), + call("capAmbientClearAll", stub.ExpectArgs{}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x8)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x9)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xa)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xb)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xc)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xd)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xe)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xf)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x10)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x11)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x12)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x13)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x14)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x15)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x16)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x17)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x18)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x19)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1a)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1b)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1c)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1d)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1e)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1f)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x20)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x21)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x22)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x23)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x24)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x25)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x26)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x27)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x28)}, nil, nil), + call("capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, new([2]capData)}, nil, nil), + call("verbose", stub.ExpectArgs{[]any{"syscall filter not configured"}}, nil, nil), + call("newFile", stub.ExpectArgs{uintptr(0x3a), "extra file 0"}, (*os.File)(nil), nil), + call("newFile", stub.ExpectArgs{uintptr(0x3b), "extra file 1"}, (*os.File)(nil), nil), + call("umask", stub.ExpectArgs{022}, 0, nil), + call("verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/run/current-system/sw/bin/bash")}}, nil, nil), + call("start", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent"}, nil, stub.UniqueError(12)), + call("fatalf", stub.ExpectArgs{"%v", []any{stub.UniqueError(12)}}, nil, nil), }, }, nil}, {"lowlastcap signaled cancel forward error", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseFalse); return nil }, stub.Expect{ /* entrypoint */ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, 0, stub.UniqueError(11)}, - {"verbosef", stub.ExpectArgs{"cannot enable ptrace protection via Yama LSM: %v", []any{stub.UniqueError(11)}}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, 0, stub.UniqueError(11)), + call("verbosef", stub.ExpectArgs{"cannot enable ptrace protection via Yama LSM: %v", []any{stub.UniqueError(11)}}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei/nonexistent"), Path: MustAbs("/run/current-system/sw/bin/bash"), Args: []string{"bash", "-c", "false"}, @@ -1986,91 +1986,91 @@ func TestInitEntrypoint(t *testing.T) { SeccompRules: make([]seccomp.NativeRule, 0), SeccompDisable: true, ParentPerm: 0750, - }, 1971, 127, 2, false}, uintptr(0x39)}, stub.UniqueError(10), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("16777216 1971 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("140737488355328 127 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(4), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1971, 127, 2, false}, uintptr(0x39)}, stub.UniqueError(10), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("16777216 1971 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("140737488355328 127 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(4), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0750)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0750)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, nil}, - {"capAmbientClearAll", stub.ExpectArgs{}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil}, - {"capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, new([2]capData)}, nil, nil}, - {"verbose", stub.ExpectArgs{[]any{"syscall filter not configured"}}, nil, nil}, - {"newFile", stub.ExpectArgs{uintptr(0x3a), "extra file 0"}, (*os.File)(nil), nil}, - {"newFile", stub.ExpectArgs{uintptr(0x3b), "extra file 1"}, (*os.File)(nil), nil}, - {"umask", stub.ExpectArgs{022}, 0, nil}, - {"verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/run/current-system/sw/bin/bash")}}, nil, nil}, - {"start", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent"}, &os.Process{Pid: 0xbad}, nil}, - {"suspend", stub.ExpectArgs{}, nil, nil}, - {"printf", stub.ExpectArgs{"cannot close setup pipe: %v", []any{stub.UniqueError(10)}}, nil, nil}, - {"New", stub.ExpectArgs{}, nil, nil}, - {"notify", stub.ExpectArgs{func(c chan<- os.Signal) { c <- CancelSignal }, []os.Signal{syscall.SIGINT, syscall.SIGTERM}}, nil, nil}, - {"resume", stub.ExpectArgs{}, true, nil}, - {"verbosef", stub.ExpectArgs{"%s after process start", []any{"terminated"}}, nil, nil}, - {"verbose", stub.ExpectArgs{[]any{"forwarding context cancellation"}}, nil, nil}, - {"signal", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent", os.Interrupt}, nil, stub.UniqueError(9)}, - {"printf", stub.ExpectArgs{"cannot forward cancellation: %v", []any{stub.UniqueError(9)}}, nil, nil}, - {"resume", stub.ExpectArgs{}, false, nil}, - {"verbosef", stub.ExpectArgs{"initial process exited with signal %s", []any{syscall.Signal(0x4e)}}, nil, nil}, - {"printf", stub.ExpectArgs{"timeout exceeded waiting for lingering processes", ([]any)(nil)}, nil, nil}, - {"beforeExit", stub.ExpectArgs{}, nil, nil}, - {"exit", stub.ExpectArgs{0xce}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, nil), + call("capAmbientClearAll", stub.ExpectArgs{}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil), + call("capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, new([2]capData)}, nil, nil), + call("verbose", stub.ExpectArgs{[]any{"syscall filter not configured"}}, nil, nil), + call("newFile", stub.ExpectArgs{uintptr(0x3a), "extra file 0"}, (*os.File)(nil), nil), + call("newFile", stub.ExpectArgs{uintptr(0x3b), "extra file 1"}, (*os.File)(nil), nil), + call("umask", stub.ExpectArgs{022}, 0, nil), + call("verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/run/current-system/sw/bin/bash")}}, nil, nil), + call("start", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent"}, &os.Process{Pid: 0xbad}, nil), + call("suspend", stub.ExpectArgs{}, nil, nil), + call("printf", stub.ExpectArgs{"cannot close setup pipe: %v", []any{stub.UniqueError(10)}}, nil, nil), + call("New", stub.ExpectArgs{}, nil, nil), + call("notify", stub.ExpectArgs{func(c chan<- os.Signal) { c <- CancelSignal }, []os.Signal{syscall.SIGINT, syscall.SIGTERM}}, nil, nil), + call("resume", stub.ExpectArgs{}, true, nil), + call("verbosef", stub.ExpectArgs{"%s after process start", []any{"terminated"}}, nil, nil), + call("verbose", stub.ExpectArgs{[]any{"forwarding context cancellation"}}, nil, nil), + call("signal", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent", os.Interrupt}, nil, stub.UniqueError(9)), + call("printf", stub.ExpectArgs{"cannot forward cancellation: %v", []any{stub.UniqueError(9)}}, nil, nil), + call("resume", stub.ExpectArgs{}, false, nil), + call("verbosef", stub.ExpectArgs{"initial process exited with signal %s", []any{syscall.Signal(0x4e)}}, nil, nil), + call("printf", stub.ExpectArgs{"timeout exceeded waiting for lingering processes", ([]any)(nil)}, nil, nil), + call("beforeExit", stub.ExpectArgs{}, nil, nil), + call("exit", stub.ExpectArgs{0xce}, nil, nil), }, /* wait4 */ Tracks: []stub.Expect{{Calls: []stub.Call{ - {"wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xfade01ce), 0, nil}, 0xbad, nil}, + call("wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xfade01ce), 0, nil}, 0xbad, nil), // this terminates the goroutine at the call, preventing it from leaking while preserving behaviour - {"wait4", stub.ExpectArgs{-1, nil, 0, nil, 0xdeadbeef}, 0, syscall.ECHILD}, + call("wait4", stub.ExpectArgs{-1, nil, 0, nil, 0xdeadbeef}, 0, syscall.ECHILD), }}}, }, nil}, {"lowlastcap signaled cancel", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseFalse); return nil }, stub.Expect{ /* entrypoint */ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, 0, stub.UniqueError(8)}, - {"verbosef", stub.ExpectArgs{"cannot enable ptrace protection via Yama LSM: %v", []any{stub.UniqueError(8)}}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, 0, stub.UniqueError(8)), + call("verbosef", stub.ExpectArgs{"cannot enable ptrace protection via Yama LSM: %v", []any{stub.UniqueError(8)}}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei/nonexistent"), Path: MustAbs("/run/current-system/sw/bin/bash"), Args: []string{"bash", "-c", "false"}, @@ -2083,84 +2083,84 @@ func TestInitEntrypoint(t *testing.T) { SeccompRules: make([]seccomp.NativeRule, 0), SeccompDisable: true, ParentPerm: 0750, - }, 1971, 127, 2, false}, uintptr(0x39)}, stub.UniqueError(7), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("16777216 1971 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("140737488355328 127 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(4), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1971, 127, 2, false}, uintptr(0x39)}, stub.UniqueError(7), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("16777216 1971 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("140737488355328 127 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(4), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0750)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0750)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, nil}, - {"capAmbientClearAll", stub.ExpectArgs{}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil}, - {"capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, new([2]capData)}, nil, nil}, - {"verbose", stub.ExpectArgs{[]any{"syscall filter not configured"}}, nil, nil}, - {"newFile", stub.ExpectArgs{uintptr(0x3a), "extra file 0"}, (*os.File)(nil), nil}, - {"newFile", stub.ExpectArgs{uintptr(0x3b), "extra file 1"}, (*os.File)(nil), nil}, - {"umask", stub.ExpectArgs{022}, 0, nil}, - {"verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/run/current-system/sw/bin/bash")}}, nil, nil}, - {"start", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent"}, &os.Process{Pid: 0xbad}, nil}, - {"suspend", stub.ExpectArgs{}, nil, nil}, - {"printf", stub.ExpectArgs{"cannot close setup pipe: %v", []any{stub.UniqueError(7)}}, nil, nil}, - {"New", stub.ExpectArgs{}, nil, nil}, - {"notify", stub.ExpectArgs{func(c chan<- os.Signal) { c <- os.Interrupt }, []os.Signal{syscall.SIGINT, syscall.SIGTERM}}, nil, nil}, - {"resume", stub.ExpectArgs{}, false, nil}, - {"verbosef", stub.ExpectArgs{"got %s", []any{"interrupt"}}, nil, nil}, - {"beforeExit", stub.ExpectArgs{}, nil, nil}, - {"exit", stub.ExpectArgs{0}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, nil), + call("capAmbientClearAll", stub.ExpectArgs{}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil), + call("capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, new([2]capData)}, nil, nil), + call("verbose", stub.ExpectArgs{[]any{"syscall filter not configured"}}, nil, nil), + call("newFile", stub.ExpectArgs{uintptr(0x3a), "extra file 0"}, (*os.File)(nil), nil), + call("newFile", stub.ExpectArgs{uintptr(0x3b), "extra file 1"}, (*os.File)(nil), nil), + call("umask", stub.ExpectArgs{022}, 0, nil), + call("verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/run/current-system/sw/bin/bash")}}, nil, nil), + call("start", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent"}, &os.Process{Pid: 0xbad}, nil), + call("suspend", stub.ExpectArgs{}, nil, nil), + call("printf", stub.ExpectArgs{"cannot close setup pipe: %v", []any{stub.UniqueError(7)}}, nil, nil), + call("New", stub.ExpectArgs{}, nil, nil), + call("notify", stub.ExpectArgs{func(c chan<- os.Signal) { c <- os.Interrupt }, []os.Signal{syscall.SIGINT, syscall.SIGTERM}}, nil, nil), + call("resume", stub.ExpectArgs{}, false, nil), + call("verbosef", stub.ExpectArgs{"got %s", []any{"interrupt"}}, nil, nil), + call("beforeExit", stub.ExpectArgs{}, nil, nil), + call("exit", stub.ExpectArgs{0}, nil, nil), }, /* wait4 */ Tracks: []stub.Expect{{Calls: []stub.Call{ // this terminates the goroutine at the call, preventing it from leaking while preserving behaviour - {"wait4", stub.ExpectArgs{-1, nil, 0, nil, 0xdeadbeef}, 0, syscall.ECHILD}, + call("wait4", stub.ExpectArgs{-1, nil, 0, nil, 0xdeadbeef}, 0, syscall.ECHILD), }}}, }, nil}, {"lowlastcap signaled timeout", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseFalse); return nil }, stub.Expect{ /* entrypoint */ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, 0, stub.UniqueError(6)}, - {"verbosef", stub.ExpectArgs{"cannot enable ptrace protection via Yama LSM: %v", []any{stub.UniqueError(6)}}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, 0, stub.UniqueError(6)), + call("verbosef", stub.ExpectArgs{"cannot enable ptrace protection via Yama LSM: %v", []any{stub.UniqueError(6)}}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei/nonexistent"), Path: MustAbs("/run/current-system/sw/bin/bash"), Args: []string{"bash", "-c", "false"}, @@ -2173,86 +2173,86 @@ func TestInitEntrypoint(t *testing.T) { SeccompRules: make([]seccomp.NativeRule, 0), SeccompDisable: true, ParentPerm: 0750, - }, 1971, 127, 2, false}, uintptr(0x39)}, stub.UniqueError(5), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("16777216 1971 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("140737488355328 127 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(4), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1971, 127, 2, false}, uintptr(0x39)}, stub.UniqueError(5), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("16777216 1971 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("140737488355328 127 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(4), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0750)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0750)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, nil}, - {"capAmbientClearAll", stub.ExpectArgs{}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil}, - {"capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, new([2]capData)}, nil, nil}, - {"verbose", stub.ExpectArgs{[]any{"syscall filter not configured"}}, nil, nil}, - {"newFile", stub.ExpectArgs{uintptr(0x3a), "extra file 0"}, (*os.File)(nil), nil}, - {"newFile", stub.ExpectArgs{uintptr(0x3b), "extra file 1"}, (*os.File)(nil), nil}, - {"umask", stub.ExpectArgs{022}, 0, nil}, - {"verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/run/current-system/sw/bin/bash")}}, nil, nil}, - {"start", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent"}, &os.Process{Pid: 0xbad}, nil}, - {"suspend", stub.ExpectArgs{}, nil, nil}, - {"printf", stub.ExpectArgs{"cannot close setup pipe: %v", []any{stub.UniqueError(5)}}, nil, nil}, - {"New", stub.ExpectArgs{}, nil, nil}, - {"notify", stub.ExpectArgs{nil, []os.Signal{syscall.SIGINT, syscall.SIGTERM}}, nil, nil}, - {"resume", stub.ExpectArgs{}, true, nil}, - {"verbosef", stub.ExpectArgs{"initial process exited with signal %s", []any{syscall.Signal(0x4e)}}, nil, nil}, - {"printf", stub.ExpectArgs{"timeout exceeded waiting for lingering processes", ([]any)(nil)}, nil, nil}, - {"beforeExit", stub.ExpectArgs{}, nil, nil}, - {"exit", stub.ExpectArgs{0xce}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, nil), + call("capAmbientClearAll", stub.ExpectArgs{}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil), + call("capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, new([2]capData)}, nil, nil), + call("verbose", stub.ExpectArgs{[]any{"syscall filter not configured"}}, nil, nil), + call("newFile", stub.ExpectArgs{uintptr(0x3a), "extra file 0"}, (*os.File)(nil), nil), + call("newFile", stub.ExpectArgs{uintptr(0x3b), "extra file 1"}, (*os.File)(nil), nil), + call("umask", stub.ExpectArgs{022}, 0, nil), + call("verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/run/current-system/sw/bin/bash")}}, nil, nil), + call("start", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent"}, &os.Process{Pid: 0xbad}, nil), + call("suspend", stub.ExpectArgs{}, nil, nil), + call("printf", stub.ExpectArgs{"cannot close setup pipe: %v", []any{stub.UniqueError(5)}}, nil, nil), + call("New", stub.ExpectArgs{}, nil, nil), + call("notify", stub.ExpectArgs{nil, []os.Signal{syscall.SIGINT, syscall.SIGTERM}}, nil, nil), + call("resume", stub.ExpectArgs{}, true, nil), + call("verbosef", stub.ExpectArgs{"initial process exited with signal %s", []any{syscall.Signal(0x4e)}}, nil, nil), + call("printf", stub.ExpectArgs{"timeout exceeded waiting for lingering processes", ([]any)(nil)}, nil, nil), + call("beforeExit", stub.ExpectArgs{}, nil, nil), + call("exit", stub.ExpectArgs{0xce}, nil, nil), }, /* wait4 */ Tracks: []stub.Expect{{Calls: []stub.Call{ - {"wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xfade01ce), 0, nil}, 0xbad, nil}, + call("wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xfade01ce), 0, nil}, 0xbad, nil), // this terminates the goroutine at the call, preventing it from leaking while preserving behaviour - {"wait4", stub.ExpectArgs{-1, nil, 0, nil, 0xdeadbeef}, 0, syscall.ECHILD}, + call("wait4", stub.ExpectArgs{-1, nil, 0, nil, 0xdeadbeef}, 0, syscall.ECHILD), }}}, }, nil}, {"lowlastcap signaled", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseFalse); return nil }, stub.Expect{ /* entrypoint */ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, 0, stub.UniqueError(4)}, - {"verbosef", stub.ExpectArgs{"cannot enable ptrace protection via Yama LSM: %v", []any{stub.UniqueError(4)}}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, 0, stub.UniqueError(4)), + call("verbosef", stub.ExpectArgs{"cannot enable ptrace protection via Yama LSM: %v", []any{stub.UniqueError(4)}}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei/nonexistent"), Path: MustAbs("/run/current-system/sw/bin/bash"), Args: []string{"bash", "-c", "false"}, @@ -2265,93 +2265,93 @@ func TestInitEntrypoint(t *testing.T) { SeccompRules: make([]seccomp.NativeRule, 0), SeccompDisable: true, ParentPerm: 0750, - }, 1971, 127, 2, false}, uintptr(0x39)}, stub.UniqueError(3), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("16777216 1971 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("140737488355328 127 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(4), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1971, 127, 2, false}, uintptr(0x39)}, stub.UniqueError(3), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("16777216 1971 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("140737488355328 127 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(4), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0750)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0750)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, nil}, - {"capAmbientClearAll", stub.ExpectArgs{}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil}, - {"capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, new([2]capData)}, nil, nil}, - {"verbose", stub.ExpectArgs{[]any{"syscall filter not configured"}}, nil, nil}, - {"newFile", stub.ExpectArgs{uintptr(0x3a), "extra file 0"}, (*os.File)(nil), nil}, - {"newFile", stub.ExpectArgs{uintptr(0x3b), "extra file 1"}, (*os.File)(nil), nil}, - {"umask", stub.ExpectArgs{022}, 0, nil}, - {"verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/run/current-system/sw/bin/bash")}}, nil, nil}, - {"start", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent"}, &os.Process{Pid: 0xbad}, nil}, - {"suspend", stub.ExpectArgs{}, nil, nil}, - {"printf", stub.ExpectArgs{"cannot close setup pipe: %v", []any{stub.UniqueError(3)}}, nil, nil}, - {"New", stub.ExpectArgs{}, nil, nil}, - {"notify", stub.ExpectArgs{nil, []os.Signal{syscall.SIGINT, syscall.SIGTERM}}, nil, nil}, - {"resume", stub.ExpectArgs{}, true, nil}, - {"verbosef", stub.ExpectArgs{"initial process exited with signal %s", []any{syscall.Signal(0x4e)}}, nil, nil}, - {"beforeExit", stub.ExpectArgs{}, nil, nil}, - {"exit", stub.ExpectArgs{0xce}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, nil), + call("capAmbientClearAll", stub.ExpectArgs{}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil), + call("capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, new([2]capData)}, nil, nil), + call("verbose", stub.ExpectArgs{[]any{"syscall filter not configured"}}, nil, nil), + call("newFile", stub.ExpectArgs{uintptr(0x3a), "extra file 0"}, (*os.File)(nil), nil), + call("newFile", stub.ExpectArgs{uintptr(0x3b), "extra file 1"}, (*os.File)(nil), nil), + call("umask", stub.ExpectArgs{022}, 0, nil), + call("verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/run/current-system/sw/bin/bash")}}, nil, nil), + call("start", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent"}, &os.Process{Pid: 0xbad}, nil), + call("suspend", stub.ExpectArgs{}, nil, nil), + call("printf", stub.ExpectArgs{"cannot close setup pipe: %v", []any{stub.UniqueError(3)}}, nil, nil), + call("New", stub.ExpectArgs{}, nil, nil), + call("notify", stub.ExpectArgs{nil, []os.Signal{syscall.SIGINT, syscall.SIGTERM}}, nil, nil), + call("resume", stub.ExpectArgs{}, true, nil), + call("verbosef", stub.ExpectArgs{"initial process exited with signal %s", []any{syscall.Signal(0x4e)}}, nil, nil), + call("beforeExit", stub.ExpectArgs{}, nil, nil), + call("exit", stub.ExpectArgs{0xce}, nil, nil), }, /* wait4 */ Tracks: []stub.Expect{{Calls: []stub.Call{ - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xdeaf), 0, nil}, 0xbabe, nil}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xfade01ce), 0, nil}, 0xbad, nil}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xdeaf), 0, nil}, 0xbabe, nil}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.ENOMEM}, - {"printf", stub.ExpectArgs{"unexpected wait4 response: %v", []any{syscall.ENOMEM}}, nil, nil}, + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xdeaf), 0, nil}, 0xbabe, nil), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xfade01ce), 0, nil}, 0xbad, nil), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xdeaf), 0, nil}, 0xbabe, nil), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.ENOMEM), + call("printf", stub.ExpectArgs{"unexpected wait4 response: %v", []any{syscall.ENOMEM}}, nil, nil), }}}, }, nil}, {"strangewait nopriv notty noseccomp yamafault", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseFalse); return nil }, stub.Expect{ /* entrypoint */ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, 0, stub.UniqueError(2)}, - {"verbosef", stub.ExpectArgs{"cannot enable ptrace protection via Yama LSM: %v", []any{stub.UniqueError(2)}}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, 0, stub.UniqueError(2)), + call("verbosef", stub.ExpectArgs{"cannot enable ptrace protection via Yama LSM: %v", []any{stub.UniqueError(2)}}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei/nonexistent"), Path: MustAbs("/run/current-system/sw/bin/bash"), Args: []string{"bash", "-c", "false"}, @@ -2364,128 +2364,128 @@ func TestInitEntrypoint(t *testing.T) { SeccompRules: make([]seccomp.NativeRule, 0), SeccompDisable: true, ParentPerm: 0750, - }, 1971, 127, 2, false}, uintptr(0x39)}, stub.UniqueError(1), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("16777216 1971 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("140737488355328 127 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1971, 127, 2, false}, uintptr(0x39)}, stub.UniqueError(1), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("16777216 1971 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("140737488355328 127 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0750)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0750)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, nil}, - {"capAmbientClearAll", stub.ExpectArgs{}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x8)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x9)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xa)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xb)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xc)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xd)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xe)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xf)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x10)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x11)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x12)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x13)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x14)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x15)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x16)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x17)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x18)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x19)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1a)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1b)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1c)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1d)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1e)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1f)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x20)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x21)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x22)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x23)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x24)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x25)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x26)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x27)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x28)}, nil, nil}, - {"capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, new([2]capData)}, nil, nil}, - {"verbose", stub.ExpectArgs{[]any{"syscall filter not configured"}}, nil, nil}, - {"newFile", stub.ExpectArgs{uintptr(0x3a), "extra file 0"}, (*os.File)(nil), nil}, - {"newFile", stub.ExpectArgs{uintptr(0x3b), "extra file 1"}, (*os.File)(nil), nil}, - {"umask", stub.ExpectArgs{022}, 0, nil}, - {"verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/run/current-system/sw/bin/bash")}}, nil, nil}, - {"start", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent"}, &os.Process{Pid: 0xbad}, nil}, - {"suspend", stub.ExpectArgs{}, nil, nil}, - {"printf", stub.ExpectArgs{"cannot close setup pipe: %v", []any{stub.UniqueError(1)}}, nil, nil}, - {"New", stub.ExpectArgs{}, nil, nil}, - {"notify", stub.ExpectArgs{nil, []os.Signal{syscall.SIGINT, syscall.SIGTERM}}, nil, nil}, - {"resume", stub.ExpectArgs{}, true, nil}, - {"verbosef", stub.ExpectArgs{"initial process exited with code %d", []any{1}}, nil, nil}, - {"beforeExit", stub.ExpectArgs{}, nil, nil}, - {"exit", stub.ExpectArgs{1}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, nil), + call("capAmbientClearAll", stub.ExpectArgs{}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x8)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x9)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xa)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xb)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xc)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xd)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xe)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xf)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x10)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x11)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x12)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x13)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x14)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x15)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x16)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x17)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x18)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x19)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1a)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1b)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1c)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1d)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1e)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1f)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x20)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x21)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x22)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x23)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x24)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x25)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x26)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x27)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x28)}, nil, nil), + call("capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, new([2]capData)}, nil, nil), + call("verbose", stub.ExpectArgs{[]any{"syscall filter not configured"}}, nil, nil), + call("newFile", stub.ExpectArgs{uintptr(0x3a), "extra file 0"}, (*os.File)(nil), nil), + call("newFile", stub.ExpectArgs{uintptr(0x3b), "extra file 1"}, (*os.File)(nil), nil), + call("umask", stub.ExpectArgs{022}, 0, nil), + call("verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/run/current-system/sw/bin/bash")}}, nil, nil), + call("start", stub.ExpectArgs{"/run/current-system/sw/bin/bash", []string{"bash", "-c", "false"}, ([]string)(nil), "/.hakurei/nonexistent"}, &os.Process{Pid: 0xbad}, nil), + call("suspend", stub.ExpectArgs{}, nil, nil), + call("printf", stub.ExpectArgs{"cannot close setup pipe: %v", []any{stub.UniqueError(1)}}, nil, nil), + call("New", stub.ExpectArgs{}, nil, nil), + call("notify", stub.ExpectArgs{nil, []os.Signal{syscall.SIGINT, syscall.SIGTERM}}, nil, nil), + call("resume", stub.ExpectArgs{}, true, nil), + call("verbosef", stub.ExpectArgs{"initial process exited with code %d", []any{1}}, nil, nil), + call("beforeExit", stub.ExpectArgs{}, nil, nil), + call("exit", stub.ExpectArgs{1}, nil, nil), }, /* wait4 */ Tracks: []stub.Expect{{Calls: []stub.Call{ - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xdeaf), 0, nil}, 0xbabe, nil}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xfade0100), 0, nil}, 0xbad, nil}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xdeaf), 0, nil}, 0xbabe, nil}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.ENOMEM}, - {"printf", stub.ExpectArgs{"unexpected wait4 response: %v", []any{syscall.ENOMEM}}, nil, nil}, + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xdeaf), 0, nil}, 0xbabe, nil), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xfade0100), 0, nil}, 0xbad, nil), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xdeaf), 0, nil}, 0xbabe, nil), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.ENOMEM), + call("printf", stub.ExpectArgs{"unexpected wait4 response: %v", []any{syscall.ENOMEM}}, nil, nil), }}}, }, nil}, {"success", func(k syscallDispatcher) error { initEntrypoint(k, assertPrefix, assertVerboseTrue); return nil }, stub.Expect{ /* entrypoint */ Calls: []stub.Call{ - {"lockOSThread", stub.ExpectArgs{}, nil, nil}, - {"getpid", stub.ExpectArgs{}, 1, nil}, - {"setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ + call("lockOSThread", stub.ExpectArgs{}, nil, nil), + call("getpid", stub.ExpectArgs{}, 1, nil), + call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr), &initParams{Params{ Dir: MustAbs("/.hakurei"), Env: []string{"DISPLAY=:0"}, Path: MustAbs("/bin/zsh"), @@ -2500,120 +2500,120 @@ func TestInitEntrypoint(t *testing.T) { SeccompPresets: seccomp.PresetStrict, RetainSession: true, Privileged: true, - }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(0), nil}, - {"verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil}, - {"writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil}, - {"setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil}, - {"umask", stub.ExpectArgs{0}, 022, nil}, - {"sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil}, - {"lastcap", stub.ExpectArgs{}, uintptr(40), nil}, - {"mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil}, + }, 1000, 100, 3, true}, uintptr(9)}, stub.UniqueError(0), nil), + call("verbose", stub.ExpectArgs{[]any{"received setup parameters"}}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(1)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/uid_map", []byte("4294967296 1000 1\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/setgroups", []byte("deny\n"), os.FileMode(0)}, nil, nil), + call("writeFile", stub.ExpectArgs{"/proc/self/gid_map", []byte("2147483648 100 1\n"), os.FileMode(0)}, nil, nil), + call("setDumpable", stub.ExpectArgs{uintptr(0)}, nil, nil), + call("umask", stub.ExpectArgs{0}, 022, nil), + call("sethostname", stub.ExpectArgs{[]byte("hakurei-check")}, nil, nil), + call("lastcap", stub.ExpectArgs{}, uintptr(40), nil), + call("mount", stub.ExpectArgs{"", "/", "", uintptr(0x8c000), ""}, nil, nil), /* begin early */ - {"evalSymlinks", stub.ExpectArgs{"/"}, "/", nil}, + call("evalSymlinks", stub.ExpectArgs{"/"}, "/", nil), /* end early */ - {"mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil}, - {"chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil}, - {"mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil}, - {"mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, + call("mount", stub.ExpectArgs{"rootfs", "/proc/self/fd", "tmpfs", uintptr(6), ""}, nil, nil), + call("chdir", stub.ExpectArgs{"/proc/self/fd"}, nil, nil), + call("mkdir", stub.ExpectArgs{"sysroot", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"sysroot", "sysroot", "", uintptr(0xd000), ""}, nil, nil), + call("mkdir", stub.ExpectArgs{"host", os.FileMode(0755)}, nil, nil), + call("pivotRoot", stub.ExpectArgs{"/proc/self/fd", "host"}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), /* begin apply */ - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil}, - {"stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil}, - {"bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil}, - {"mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil}, - {"mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil}, + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &BindMountOp{sourceFinal: MustAbs("/"), Source: MustAbs("/"), Target: MustAbs("/"), Flags: BindDevice}}}, nil, nil), + call("stat", stub.ExpectArgs{"/host"}, isDirFi(true), nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot", os.FileMode(0700)}, nil, nil), + call("bindMount", stub.ExpectArgs{"/host", "/sysroot", uintptr(0x4001), false}, nil, nil), + call("verbosef", stub.ExpectArgs{"%s %s", []any{"mounting", &MountProcOp{Target: MustAbs("/proc/")}}}, nil, nil), + call("mkdirAll", stub.ExpectArgs{"/sysroot/proc", os.FileMode(0755)}, nil, nil), + call("mount", stub.ExpectArgs{"proc", "/sysroot/proc", "proc", uintptr(0xe), ""}, nil, nil), /* end apply */ - {"mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil}, - {"unmount", stub.ExpectArgs{"host", 2}, nil, nil}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, syscall.EINTR}, - {"open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1 << 35, nil}, - {"chdir", stub.ExpectArgs{"/sysroot"}, nil, nil}, - {"pivotRoot", stub.ExpectArgs{".", "."}, nil, nil}, - {"fchdir", stub.ExpectArgs{1 << 35}, nil, nil}, - {"unmount", stub.ExpectArgs{".", 2}, nil, nil}, - {"chdir", stub.ExpectArgs{"/"}, nil, nil}, - {"close", stub.ExpectArgs{1 << 35}, nil, nil}, - {"capAmbientClearAll", stub.ExpectArgs{}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x8)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x9)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xa)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xb)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xc)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xd)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xe)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0xf)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x10)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x11)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x12)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x13)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x14)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x16)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x17)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x18)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x19)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1a)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1b)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1c)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1d)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1e)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1f)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x20)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x21)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x22)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x23)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x24)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x25)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x26)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x27)}, nil, nil}, - {"capBoundingSetDrop", stub.ExpectArgs{uintptr(0x28)}, nil, nil}, - {"capAmbientRaise", stub.ExpectArgs{uintptr(0x15)}, nil, nil}, - {"capset", stub.ExpectArgs{&capHeader{_LINUX_CAPABILITY_VERSION_3, 0}, &[2]capData{{0, 0x200000, 0x200000}, {0, 0, 0}}}, nil, nil}, - {"verbosef", stub.ExpectArgs{"resolving presets %#x", []any{seccomp.FilterPreset(0xf)}}, nil, nil}, - {"seccompLoad", stub.ExpectArgs{seccomp.Preset(0xf, 0), seccomp.ExportFlag(0)}, nil, nil}, - {"verbosef", stub.ExpectArgs{"%d filter rules loaded", []any{73}}, nil, nil}, - {"newFile", stub.ExpectArgs{uintptr(10), "extra file 0"}, (*os.File)(nil), nil}, - {"newFile", stub.ExpectArgs{uintptr(11), "extra file 1"}, (*os.File)(nil), nil}, - {"newFile", stub.ExpectArgs{uintptr(12), "extra file 2"}, (*os.File)(nil), nil}, - {"umask", stub.ExpectArgs{022}, 0, nil}, - {"verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/bin/zsh")}}, nil, nil}, - {"start", stub.ExpectArgs{"/bin/zsh", []string{"zsh", "-c", "exec vim"}, []string{"DISPLAY=:0"}, "/.hakurei"}, &os.Process{Pid: 0xcafe}, nil}, - {"suspend", stub.ExpectArgs{}, nil, nil}, - {"printf", stub.ExpectArgs{"cannot close setup pipe: %v", []any{stub.UniqueError(0)}}, nil, nil}, - {"New", stub.ExpectArgs{}, nil, nil}, - {"notify", stub.ExpectArgs{nil, []os.Signal{syscall.SIGINT, syscall.SIGTERM}}, nil, nil}, - {"resume", stub.ExpectArgs{}, true, nil}, - {"verbosef", stub.ExpectArgs{"initial process exited with status %#x", []any{syscall.WaitStatus(0xfade007f)}}, nil, nil}, - {"beforeExit", stub.ExpectArgs{}, nil, nil}, - {"exit", stub.ExpectArgs{0xff}, nil, nil}, + call("mount", stub.ExpectArgs{"host", "host", "", uintptr(0x4c000), ""}, nil, nil), + call("unmount", stub.ExpectArgs{"host", 2}, nil, nil), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, syscall.EINTR), + call("open", stub.ExpectArgs{"/", 0x10000, uint32(0)}, 1<<35, nil), + call("chdir", stub.ExpectArgs{"/sysroot"}, nil, nil), + call("pivotRoot", stub.ExpectArgs{".", "."}, nil, nil), + call("fchdir", stub.ExpectArgs{1 << 35}, nil, nil), + call("unmount", stub.ExpectArgs{".", 2}, nil, nil), + call("chdir", stub.ExpectArgs{"/"}, nil, nil), + call("close", stub.ExpectArgs{1 << 35}, nil, nil), + call("capAmbientClearAll", stub.ExpectArgs{}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x0)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x2)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x3)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x4)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x5)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x6)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x7)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x8)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x9)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xa)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xb)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xc)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xd)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xe)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0xf)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x10)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x11)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x12)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x13)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x14)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x16)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x17)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x18)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x19)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1a)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1b)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1c)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1d)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1e)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x1f)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x20)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x21)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x22)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x23)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x24)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x25)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x26)}, nil, nil), + call("capBoundingSetDrop", stub.ExpectArgs{uintptr(0x27)}, nil, nil), + 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{seccomp.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), + call("newFile", stub.ExpectArgs{uintptr(11), "extra file 1"}, (*os.File)(nil), nil), + call("newFile", stub.ExpectArgs{uintptr(12), "extra file 2"}, (*os.File)(nil), nil), + call("umask", stub.ExpectArgs{022}, 0, nil), + call("verbosef", stub.ExpectArgs{"starting initial program %s", []any{MustAbs("/bin/zsh")}}, nil, nil), + call("start", stub.ExpectArgs{"/bin/zsh", []string{"zsh", "-c", "exec vim"}, []string{"DISPLAY=:0"}, "/.hakurei"}, &os.Process{Pid: 0xcafe}, nil), + call("suspend", stub.ExpectArgs{}, nil, nil), + call("printf", stub.ExpectArgs{"cannot close setup pipe: %v", []any{stub.UniqueError(0)}}, nil, nil), + call("New", stub.ExpectArgs{}, nil, nil), + call("notify", stub.ExpectArgs{nil, []os.Signal{syscall.SIGINT, syscall.SIGTERM}}, nil, nil), + call("resume", stub.ExpectArgs{}, true, nil), + call("verbosef", stub.ExpectArgs{"initial process exited with status %#x", []any{syscall.WaitStatus(0xfade007f)}}, nil, nil), + call("beforeExit", stub.ExpectArgs{}, nil, nil), + call("exit", stub.ExpectArgs{0xff}, nil, nil), }, /* wait4 */ Tracks: []stub.Expect{{Calls: []stub.Call{ - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xdeaf), 0, nil}, 0xbabe, nil}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xfade007f), 0, nil}, 0xcafe, nil}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR}, - {"wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xdeaf), 0, nil}, 0xbabe, nil}, - {"wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.ECHILD}, + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xdeaf), 0, nil}, 0xbabe, nil), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xfade007f), 0, nil}, 0xcafe, nil), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.EINTR), + call("wait4", stub.ExpectArgs{-1, syscall.WaitStatus(0xdeaf), 0, nil}, 0xbabe, nil), + call("wait4", stub.ExpectArgs{-1, nil, 0, nil}, 0, syscall.ECHILD), }}}, }, nil}, }) |
