container/params: pass fd instead of file
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m9s
Test / Hakurei (push) Successful in 3m9s
Test / Hpkg (push) Successful in 4m12s
Test / Sandbox (race detector) (push) Successful in 4m29s
Test / Hakurei (race detector) (push) Successful in 5m6s
Test / Flake checks (push) Successful in 1m29s

The file is very difficult to stub. Pass fd instead as it is the value that is actually useful.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-08-23 00:16:46 +09:00
parent 1c692bfb79
commit ea1e3ebae9
5 changed files with 19 additions and 22 deletions

View File

@@ -99,10 +99,10 @@ func initEntrypoint(k syscallDispatcher, prepareLogger func(prefix string), setV
var (
params initParams
closeSetup func() error
setupFile *os.File
setupFd uintptr
offsetSetup int
)
if f, err := k.receive(setupEnv, &params, &setupFile); err != nil {
if f, err := k.receive(setupEnv, &params, &setupFd); err != nil {
if errors.Is(err, EBADF) {
k.fatal("invalid setup descriptor")
}
@@ -122,7 +122,7 @@ func initEntrypoint(k syscallDispatcher, prepareLogger func(prefix string), setV
setVerbose(params.Verbose)
k.verbose("received setup parameters")
closeSetup = f
offsetSetup = int(setupFile.Fd() + 1)
offsetSetup = int(setupFd + 1)
}
// write uid/gid map here so parent does not need to set dumpable