From 87b5c30ef6d5b7b8a10d6a5a8610054c403923e6 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 9 Oct 2025 05:04:08 +0900 Subject: message: relocate from container This package is quite useful. This change allows it to be imported without importing container. Signed-off-by: Ophestra --- container/init.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'container/init.go') diff --git a/container/init.go b/container/init.go index 9481acd1..923a36e8 100644 --- a/container/init.go +++ b/container/init.go @@ -14,6 +14,7 @@ import ( "hakurei.app/container/fhs" "hakurei.app/container/seccomp" + "hakurei.app/message" ) const ( @@ -61,7 +62,7 @@ type ( setupState struct { nonrepeatable uintptr *Params - Msg + message.Msg } ) @@ -95,14 +96,14 @@ type initParams struct { } // Init is called by [TryArgv0] if the current process is the container init. -func Init(msg Msg) { +func Init(msg message.Msg) { if msg == nil { panic("attempting to call initEntrypoint with nil msg") } initEntrypoint(direct{}, msg) } -func initEntrypoint(k syscallDispatcher, msg Msg) { +func initEntrypoint(k syscallDispatcher, msg message.Msg) { k.lockOSThread() if k.getpid() != 1 { @@ -125,7 +126,7 @@ func initEntrypoint(k syscallDispatcher, msg Msg) { k.fatal(msg, "invalid setup descriptor") } if errors.Is(err, ErrReceiveEnv) { - k.fatal(msg, "HAKUREI_SETUP not set") + k.fatal(msg, setupEnv+" not set") } k.fatalf(msg, "cannot decode init setup payload: %v", err) @@ -448,11 +449,11 @@ const initName = "init" // TryArgv0 calls [Init] if the last element of argv0 is "init". // If a nil msg is passed, the system logger is used instead. -func TryArgv0(msg Msg) { +func TryArgv0(msg message.Msg) { if msg == nil { log.SetPrefix(initName + ": ") log.SetFlags(0) - msg = NewMsg(log.Default()) + msg = message.NewMsg(log.Default()) } if len(os.Args) > 0 && path.Base(os.Args[0]) == initName { -- cgit v1.3.1