package hostfiles import "fmt" // ValidateManifest checks every entry and platform item of m against the // admitted origins, as Restore and CopyManifest do before they touch // anything (contracts note ยง1). A caller holding a manifest's exact bytes // from somewhere other than its prefix (a relocation's retained copy) // validates them with it before writing them under a new generation. func ValidateManifest(m Manifest, origins []string) error { if m.V != ManifestVersion { return fmt.Errorf("hostfiles: manifest is version %d; this binary reads %d", m.V, ManifestVersion) } if len(origins) == 0 { return ErrOrigin } for _, o := range origins { if err := checkPrefix(o); err != nil { return err } } return checkManifest(m, origins) }