repair

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package repair finds what is wrong with an authama home, ~/.ssh and the token files, and fixes what can be fixed without guessing.

It composes the services that already own each fix - doctor's permission rules, pubkeys' .pub regeneration, configsvc's render, the history store's integrity check - rather than doing any of them a second way. A finding it cannot fix safely (an unreadable manifest, a seal that no longer matches) is reported with the command that deals with it, never patched over.

Nothing is deleted. A corrupt history database is renamed aside, and a new one is created and filled from audit.log the next time authama records.

Index

Constants

This section is empty.

Variables

View Source
var Areas = []Area{Tool, SSH, Tokens}

Areas lists every area, in the order they are checked.

View Source
var ErrHistoryPermanent = errors.New("the history is kept for good (history.permanent is on); turn it off in authama.json to start the history again")

ErrHistoryPermanent is what a history reset says when history.permanent (AUTHAMA_HISTORY_PERMANENT) is on.

Functions

func Fix

func Fix(findings []Finding, out io.Writer) error

Fix applies every fixable finding, in order, and reports what it did. It goes on past a fix that fails, so one bad file does not stop the rest, and returns the failures joined.

func HistoryPermanent

func HistoryPermanent(get envnames.Getenv) bool

HistoryPermanent reports whether history.permanent is on, so the history may never be set aside.

func PlanHistoryReset

func PlanHistoryReset(p paths.Paths, now time.Time) [][2]string

PlanHistoryReset says what ResetHistory would move aside, and where: the history database (and its write-ahead files) and the audit log it rebuilds itself from.

func ResetHistory

func ResetHistory(p paths.Paths, now time.Time, get envnames.Getenv) ([][2]string, error)

ResetHistory starts the history again, and deletes nothing: the history database and the audit log are renamed aside, so renaming them back undoes it. Both go, because a new history imports the audit log the first time it is opened; moving the database alone would bring the old record straight back. The next change starts a new history, which first lists what is on disk now (keys' dates, snapshots) as backfill. It refuses while history.permanent is on.

Types

type Area

type Area string

Area is what a finding concerns.

const (
	Tool   Area = "tool"   // the config and state homes, the history
	SSH    Area = "ssh"    // ~/.ssh: modes, public keys, the rendered config
	Tokens Area = "tokens" // the tools' credential files
)

type Finding

type Finding struct {
	Area    Area
	Problem string
	// Fix says what Fix will do, when Fixable; otherwise what the person
	// should do, usually a command.
	Fix     string
	Fixable bool
	// contains filtered or unexported fields
}

Finding is one thing wrong, and how it is put right.

type Home

type Home struct {
	P paths.Paths
	// Tokens resolves the tools' credential files; nil skips the token area.
	Tokens *tokensvc.Env
	// EmitUseKeychain is the rendered config's macOS UseKeychain setting, as
	// the command that renders it decides.
	EmitUseKeychain bool
	Now             func() time.Time
}

Home is what a repair works on.

func (Home) Check

func (h Home) Check(areas ...Area) []Finding

Check finds what is wrong in the areas asked for (all when none are). It changes nothing.

type ResetPlan

type ResetPlan struct {
	Moves   [][2]string // from, to
	Unbinds bool        // the home is bound to an owner, and is unbound first
}

ResetPlan is what a factory reset would do, for the person to read first.

func FactoryReset

func FactoryReset(p paths.Paths, now time.Time) (ResetPlan, error)

FactoryReset puts authama back to how it was before it was set up, and deletes nothing: the config home (and the state home, when separate) are renamed aside, so renaming them back undoes it. ~/.ssh is not touched - the keys, the config file and known_hosts stay as they are.

A bound home is unbound first. Its sealing key lives in the OS store, not in the folder that is moved, so a home renamed back later would otherwise come back bound to a key that a new binding may have replaced: asking for a PIN that no reset could replace. Unbinding first means a restored home simply has no owner, and can be bound again.

func PlanFactoryReset

func PlanFactoryReset(p paths.Paths, now time.Time) ResetPlan

PlanFactoryReset says what FactoryReset would move, and where.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL