diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-22 04:20:08 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-22 04:20:08 +0900 |
| commit | 622f945c22d785b0ab5fd85fa2f32e0c68c647f1 (patch) | |
| tree | dcfe9d40a53ba8e4d5894294acee462245f0ddf0 /container | |
| parent | e94acc424c5746eb6cf903ed97b4e71223fda50f (diff) | |
container/init: check msg in entrypoint
This covers invalid call to Init.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container')
| -rw-r--r-- | container/init.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/container/init.go b/container/init.go index e38127fd..4e2345b3 100644 --- a/container/init.go +++ b/container/init.go @@ -96,16 +96,15 @@ type initParams struct { } // Init is called by [TryArgv0] if the current process is the container init. -func Init(msg message.Msg) { - if msg == nil { - panic("attempting to call initEntrypoint with nil msg") - } - initEntrypoint(direct{}, msg) -} +func Init(msg message.Msg) { initEntrypoint(direct{}, msg) } func initEntrypoint(k syscallDispatcher, msg message.Msg) { k.lockOSThread() + if msg == nil { + panic("attempting to call initEntrypoint with nil msg") + } + if k.getpid() != 1 { k.fatal(msg, "this process must run as pid 1") } @@ -451,6 +450,7 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) { } } +// initName is the prefix used by log.std in the init process. const initName = "init" // TryArgv0 calls [Init] if the last element of argv0 is "init". |
