package host import ( "context" "os" "github.com/carlosframework/platform/internal/hostguard" "github.com/carlosframework/platform/internal/release" ) func rootInstallationHostApp(guard hostguard.Guard, store release.Store) func(string) (string, string, error) { return func(host string) (string, string, error) { if guard.Root == nil || guard.Claims == nil || store == nil { return "", "", os.ErrPermission } captured, err := guard.Capture(host) if err != nil { return "", "", err } in, err := guard.Root.Installation(context.Background(), host, captured) if err != nil { return "", "", err } observed, err := guard.Claims.Read(context.Background(), host) if err != nil { return "", "", err } if observed.Absent || observed.Host != host || observed.Claim == nil || observed.Claim.Holder == nil { return "", "", os.ErrPermission } h := observed.Claim.Holder if h.Incarnation != in.Incarnation || h.Stamp != in.Stamp || h.Account != in.Account || h.App != in.App || h.Key != in.Record { return "", "", os.ErrPermission } rec, _, err := rootClaimRecord(context.Background(), store, observed.Claim, guard.DataDir) if err != nil { return "", "", err } if rec.Account != in.Account || rec.App != in.App { return "", "", os.ErrPermission } return in.Account, in.App, nil } }