container/init: check msg in entrypoint
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m14s
Test / Hakurei (push) Successful in 3m10s
Test / Sandbox (race detector) (push) Successful in 3m59s
Test / Hpkg (push) Successful in 4m8s
Test / Hakurei (race detector) (push) Successful in 4m46s
Test / Flake checks (push) Successful in 1m27s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m14s
Test / Hakurei (push) Successful in 3m10s
Test / Sandbox (race detector) (push) Successful in 3m59s
Test / Hpkg (push) Successful in 4m8s
Test / Hakurei (race detector) (push) Successful in 4m46s
Test / Flake checks (push) Successful in 1m27s
This covers invalid call to Init. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
e94acc424c
commit
622f945c22
@ -96,16 +96,15 @@ type initParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init is called by [TryArgv0] if the current process is the container init.
|
// Init is called by [TryArgv0] if the current process is the container init.
|
||||||
func Init(msg message.Msg) {
|
func Init(msg message.Msg) { initEntrypoint(direct{}, msg) }
|
||||||
if msg == nil {
|
|
||||||
panic("attempting to call initEntrypoint with nil msg")
|
|
||||||
}
|
|
||||||
initEntrypoint(direct{}, msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
||||||
k.lockOSThread()
|
k.lockOSThread()
|
||||||
|
|
||||||
|
if msg == nil {
|
||||||
|
panic("attempting to call initEntrypoint with nil msg")
|
||||||
|
}
|
||||||
|
|
||||||
if k.getpid() != 1 {
|
if k.getpid() != 1 {
|
||||||
k.fatal(msg, "this process must run as pid 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"
|
const initName = "init"
|
||||||
|
|
||||||
// TryArgv0 calls [Init] if the last element of argv0 is "init".
|
// TryArgv0 calls [Init] if the last element of argv0 is "init".
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user