//go:build linux package host import ( "context" "github.com/carlosframework/platform/internal/hostbox" "github.com/carlosframework/platform/internal/hostguard" "github.com/carlosframework/platform/internal/provision" ) func (h ClaimRootHTTP) verifyServingHandoverDirectory(ctx context.Context, prior hostguard.FenceTarget, e hostbox.StopInventoryEntry, actual hostbox.Artifact) error { if h.servingParks == nil || h.servingParks.authority == nil { return hostbox.ErrChanged } authority, ok := h.servingParks.authority.(*servingParkRoot) if !ok { return hostbox.ErrChanged } l := authority.ledger if l == nil { return hostbox.ErrChanged } fs, ok := l.fs.(*servingParkFS) if !ok { return hostbox.ErrChanged } boot, err := fs.currentBoot() if err != nil || !validServingParkBootID(prior.BootID) { return hostbox.ErrChanged } if prior.BootID == boot { if actual.Dev != e.Device { return hostbox.ErrChanged } return ctx.Err() } slot, err := l.slot(servingParkAuthorization{Successor: servingArtifactIdentity{Host: prior.Host, Box: prior.Box}}) if err != nil { return err } r, err := l.readHistorical(slot.Last) if err != nil { return err } s := r.Authorization.Successor if !r.Complete || s.Host != prior.Host || s.Box != prior.Box || s.Incarnation != prior.Incarnation || s.Stamp > prior.Stamp || e.Kind != "path" || e.ManagedRoot != "data" || e.RelativePath != "instances/"+provision.InstanceID(prior.Host) || e.Inode != r.Source.Directory.Inode || actual.Ino != e.Inode || actual.Type != 0040000 || e.Type != actual.Type { return hostbox.ErrChanged } if _, err := fs.readNamespace(); err != nil { return err } root, n, err := fs.namespace() if err != nil { return err } root.Close() parent, pid, err := fs.parent() if err != nil { return err } defer parent.Close() if pid != n.Parent { return hostbox.ErrChanged } source, err := servingParkOpenDir(parent, provision.InstanceID(prior.Host)) if err != nil { return err } defer source.Close() id, err := fs.rebootDirectory(source, r.Source.Directory, r.Source.Persistent, pid) if err != nil || id.Device != actual.Dev || id.Inode != actual.Ino { return hostbox.ErrChanged } if err := fs.checkBoot(boot); err != nil { return err } return ctx.Err() }