metropolis/node/core: fix invalid write in console setup
When configuring the console writers, we are iterating over a slice of
console structs, this is fine by itself, but we are also storing a
reference to the logtree reader. Since we are iterating over a struct
value and aren't using a pointer, this write won't persist into the
underlying slice and we cannot close the reader anymore. By using a
pointer to a struct instead of the raw value the issue is fixed.
Change-Id: Iaf753345cd275a03aecf9748b344c60eefcf9d69
Reviewed-on: https://review.monogon.dev/c/monogon/+/2973
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/node/core/panichandler.go b/metropolis/node/core/panichandler.go
index 7a6534b..f1b4c6f 100644
--- a/metropolis/node/core/panichandler.go
+++ b/metropolis/node/core/panichandler.go
@@ -54,7 +54,7 @@
return int32(err)
}
-func initPanicHandler(lt *logtree.LogTree, consoles []console) {
+func initPanicHandler(lt *logtree.LogTree, consoles []*console) {
l := lt.MustLeveledFor("panichandler")
// Setup pstore userspace message buffer
@@ -66,11 +66,11 @@
runtimeFds = append(runtimeFds, fd)
}
- for _, console := range consoles {
- fd, err := unix.Open(console.path, os.O_WRONLY, 0)
+ for _, c := range consoles {
+ fd, err := unix.Open(c.path, os.O_WRONLY, 0)
if err == nil {
runtimeFds = append(runtimeFds, fd)
- l.Infof("Panic console: %s", console.path)
+ l.Infof("Panic console: %s", c.path)
}
}