//go:build linux package host import ( "io" "os" "github.com/carlosframework/platform/internal/hostbox" ) func servingParkBootID() (string, error) { f, err := os.Open("/proc/sys/kernel/random/boot_id") if err != nil { return "", err } defer f.Close() b, err := io.ReadAll(io.LimitReader(f, 38)) if err != nil || len(b) != 37 || b[36] != '\n' { return "", hostbox.ErrChanged } return string(b[:36]), nil } func (f *servingParkFS) currentBoot() (string, error) { if f == nil || f.boot == nil { return "", hostbox.ErrUnsupported } id, err := f.boot() if err != nil { return "", err } if !validServingParkBootID(id) { return "", hostbox.ErrChanged } return id, nil } // A mount number is meaningful only in the boot that supplied it. Old records // without a boot remain readable, but cannot authorize namespace mutations. func (f *servingParkFS) checkBoot(expected string) error { current, err := f.currentBoot() if err != nil { return err } if expected == "" || current != expected { return hostbox.ErrChanged } return nil } func (f *servingParkFS) checkRecordBoot(r *servingParkRecord) error { if r.Source.BootID != "" { return f.checkBoot(r.Source.BootID) } b, err := servingParkReadBinding(f.state, "namespace") if err != nil { return err } if b != nil { return hostbox.ErrChanged } return nil }