diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-04-07 16:31:46 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-04-07 16:37:44 +0900 |
| commit | c61cdc505f05decd940cb2d861241039a49251e3 (patch) | |
| tree | e6f34ad86c7a4d0e98b896cd37d4f77cbcb9ea66 /internal/outcome | |
| parent | 062edb3487c1cc116cae78bf77420b65c43517d1 (diff) | |
internal/params: relocate from package container
This does not make sense as part of the public API, so make it internal.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/outcome')
| -rw-r--r-- | internal/outcome/dispatcher.go | 7 | ||||
| -rw-r--r-- | internal/outcome/dispatcher_test.go | 68 | ||||
| -rw-r--r-- | internal/outcome/shim.go | 3 | ||||
| -rw-r--r-- | internal/outcome/shim_test.go | 3 |
4 files changed, 42 insertions, 39 deletions
diff --git a/internal/outcome/dispatcher.go b/internal/outcome/dispatcher.go index a3d3dbbc..892e6baf 100644 --- a/internal/outcome/dispatcher.go +++ b/internal/outcome/dispatcher.go @@ -17,6 +17,7 @@ import ( "hakurei.app/ext" "hakurei.app/internal/dbus" "hakurei.app/internal/info" + "hakurei.app/internal/params" "hakurei.app/message" ) @@ -84,7 +85,7 @@ type syscallDispatcher interface { // setDumpable provides [container.SetDumpable]. setDumpable(dumpable uintptr) error // receive provides [container.Receive]. - receive(key string, e any, fdp *uintptr) (closeFunc func() error, err error) + receive(key string, e any, fdp *int) (closeFunc func() error, err error) // containerStart provides the Start method of [container.Container]. containerStart(z *container.Container) error @@ -154,8 +155,8 @@ func (direct) prctl(op, arg2, arg3 uintptr) error { return ext.Prctl(op, arg2, a func (direct) overflowUid(msg message.Msg) int { return container.OverflowUid(msg) } func (direct) overflowGid(msg message.Msg) int { return container.OverflowGid(msg) } func (direct) setDumpable(dumpable uintptr) error { return ext.SetDumpable(dumpable) } -func (direct) receive(key string, e any, fdp *uintptr) (func() error, error) { - return container.Receive(key, e, fdp) +func (direct) receive(key string, e any, fdp *int) (func() error, error) { + return params.Receive(key, e, fdp) } func (direct) containerStart(z *container.Container) error { return z.Start() } diff --git a/internal/outcome/dispatcher_test.go b/internal/outcome/dispatcher_test.go index a099df58..9ae2ba52 100644 --- a/internal/outcome/dispatcher_test.go +++ b/internal/outcome/dispatcher_test.go @@ -401,12 +401,12 @@ func (k *kstub) setDumpable(dumpable uintptr) error { stub.CheckArg(k.Stub, "dumpable", dumpable, 0)) } -func (k *kstub) receive(key string, e any, fdp *uintptr) (closeFunc func() error, err error) { +func (k *kstub) receive(key string, e any, fdp *int) (closeFunc func() error, err error) { k.Helper() expect := k.Expects("receive") reflect.ValueOf(e).Elem().Set(reflect.ValueOf(expect.Args[1])) if expect.Args[2] != nil { - *fdp = expect.Args[2].(uintptr) + *fdp = int(expect.Args[2].(uintptr)) } return func() error { return k.Expects("closeReceive").Err }, expect.Error( stub.CheckArg(k.Stub, "key", key, 0)) @@ -690,38 +690,38 @@ func (panicMsgContext) Value(any) any { panic("unreachable") } // This type is meant to be embedded in partial syscallDispatcher implementations. type panicDispatcher struct{} -func (panicDispatcher) new(func(k syscallDispatcher, msg message.Msg)) { panic("unreachable") } -func (panicDispatcher) getppid() int { panic("unreachable") } -func (panicDispatcher) getpid() int { panic("unreachable") } -func (panicDispatcher) getuid() int { panic("unreachable") } -func (panicDispatcher) getgid() int { panic("unreachable") } -func (panicDispatcher) lookupEnv(string) (string, bool) { panic("unreachable") } -func (panicDispatcher) pipe() (*os.File, *os.File, error) { panic("unreachable") } -func (panicDispatcher) stat(string) (os.FileInfo, error) { panic("unreachable") } -func (panicDispatcher) open(string) (osFile, error) { panic("unreachable") } -func (panicDispatcher) readdir(string) ([]os.DirEntry, error) { panic("unreachable") } -func (panicDispatcher) tempdir() string { panic("unreachable") } -func (panicDispatcher) mkdir(string, os.FileMode) error { panic("unreachable") } -func (panicDispatcher) removeAll(string) error { panic("unreachable") } -func (panicDispatcher) exit(int) { panic("unreachable") } -func (panicDispatcher) evalSymlinks(string) (string, error) { panic("unreachable") } -func (panicDispatcher) prctl(uintptr, uintptr, uintptr) error { panic("unreachable") } -func (panicDispatcher) lookupGroupId(string) (string, error) { panic("unreachable") } -func (panicDispatcher) lookPath(string) (string, error) { panic("unreachable") } -func (panicDispatcher) cmdOutput(*exec.Cmd) ([]byte, error) { panic("unreachable") } -func (panicDispatcher) overflowUid(message.Msg) int { panic("unreachable") } -func (panicDispatcher) overflowGid(message.Msg) int { panic("unreachable") } -func (panicDispatcher) setDumpable(uintptr) error { panic("unreachable") } -func (panicDispatcher) receive(string, any, *uintptr) (func() error, error) { panic("unreachable") } -func (panicDispatcher) containerStart(*container.Container) error { panic("unreachable") } -func (panicDispatcher) containerServe(*container.Container) error { panic("unreachable") } -func (panicDispatcher) containerWait(*container.Container) error { panic("unreachable") } -func (panicDispatcher) mustHsuPath() *check.Absolute { panic("unreachable") } -func (panicDispatcher) dbusAddress() (string, string) { panic("unreachable") } -func (panicDispatcher) setupContSignal(int) (io.ReadCloser, func(), error) { panic("unreachable") } -func (panicDispatcher) getMsg() message.Msg { panic("unreachable") } -func (panicDispatcher) fatal(...any) { panic("unreachable") } -func (panicDispatcher) fatalf(string, ...any) { panic("unreachable") } +func (panicDispatcher) new(func(k syscallDispatcher, msg message.Msg)) { panic("unreachable") } +func (panicDispatcher) getppid() int { panic("unreachable") } +func (panicDispatcher) getpid() int { panic("unreachable") } +func (panicDispatcher) getuid() int { panic("unreachable") } +func (panicDispatcher) getgid() int { panic("unreachable") } +func (panicDispatcher) lookupEnv(string) (string, bool) { panic("unreachable") } +func (panicDispatcher) pipe() (*os.File, *os.File, error) { panic("unreachable") } +func (panicDispatcher) stat(string) (os.FileInfo, error) { panic("unreachable") } +func (panicDispatcher) open(string) (osFile, error) { panic("unreachable") } +func (panicDispatcher) readdir(string) ([]os.DirEntry, error) { panic("unreachable") } +func (panicDispatcher) tempdir() string { panic("unreachable") } +func (panicDispatcher) mkdir(string, os.FileMode) error { panic("unreachable") } +func (panicDispatcher) removeAll(string) error { panic("unreachable") } +func (panicDispatcher) exit(int) { panic("unreachable") } +func (panicDispatcher) evalSymlinks(string) (string, error) { panic("unreachable") } +func (panicDispatcher) prctl(uintptr, uintptr, uintptr) error { panic("unreachable") } +func (panicDispatcher) lookupGroupId(string) (string, error) { panic("unreachable") } +func (panicDispatcher) lookPath(string) (string, error) { panic("unreachable") } +func (panicDispatcher) cmdOutput(*exec.Cmd) ([]byte, error) { panic("unreachable") } +func (panicDispatcher) overflowUid(message.Msg) int { panic("unreachable") } +func (panicDispatcher) overflowGid(message.Msg) int { panic("unreachable") } +func (panicDispatcher) setDumpable(uintptr) error { panic("unreachable") } +func (panicDispatcher) receive(string, any, *int) (func() error, error) { panic("unreachable") } +func (panicDispatcher) containerStart(*container.Container) error { panic("unreachable") } +func (panicDispatcher) containerServe(*container.Container) error { panic("unreachable") } +func (panicDispatcher) containerWait(*container.Container) error { panic("unreachable") } +func (panicDispatcher) mustHsuPath() *check.Absolute { panic("unreachable") } +func (panicDispatcher) dbusAddress() (string, string) { panic("unreachable") } +func (panicDispatcher) setupContSignal(int) (io.ReadCloser, func(), error) { panic("unreachable") } +func (panicDispatcher) getMsg() message.Msg { panic("unreachable") } +func (panicDispatcher) fatal(...any) { panic("unreachable") } +func (panicDispatcher) fatalf(string, ...any) { panic("unreachable") } func (panicDispatcher) notifyContext(context.Context, ...os.Signal) (context.Context, context.CancelFunc) { panic("unreachable") diff --git a/internal/outcome/shim.go b/internal/outcome/shim.go index d2706c8b..b2074928 100644 --- a/internal/outcome/shim.go +++ b/internal/outcome/shim.go @@ -20,6 +20,7 @@ import ( "hakurei.app/ext" "hakurei.app/fhs" "hakurei.app/hst" + "hakurei.app/internal/params" "hakurei.app/internal/pipewire" "hakurei.app/message" ) @@ -197,7 +198,7 @@ func shimEntrypoint(k syscallDispatcher) { if errors.Is(err, syscall.EBADF) { k.fatal("invalid config descriptor") } - if errors.Is(err, container.ErrReceiveEnv) { + if errors.Is(err, params.ErrReceiveEnv) { k.fatal(shimEnv + " not set") } diff --git a/internal/outcome/shim_test.go b/internal/outcome/shim_test.go index 08f037da..6d9a9f3d 100644 --- a/internal/outcome/shim_test.go +++ b/internal/outcome/shim_test.go @@ -16,6 +16,7 @@ import ( "hakurei.app/fhs" "hakurei.app/hst" "hakurei.app/internal/env" + "hakurei.app/internal/params" "hakurei.app/internal/stub" ) @@ -172,7 +173,7 @@ func TestShimEntrypoint(t *testing.T) { call("setDumpable", stub.ExpectArgs{uintptr(ext.SUID_DUMP_DISABLE)}, nil, nil), call("getppid", stub.ExpectArgs{}, 0xbad, nil), call("setupContSignal", stub.ExpectArgs{0xbad}, 0, nil), - call("receive", stub.ExpectArgs{"HAKUREI_SHIM", outcomeState{}, nil}, nil, container.ErrReceiveEnv), + call("receive", stub.ExpectArgs{"HAKUREI_SHIM", outcomeState{}, nil}, nil, params.ErrReceiveEnv), call("fatal", stub.ExpectArgs{[]any{"HAKUREI_SHIM not set"}}, nil, nil), // deferred |
