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 ¶
- Variables
- func Fix(findings []Finding, out io.Writer) error
- func HistoryPermanent(get envnames.Getenv) bool
- func PlanHistoryReset(p paths.Paths, now time.Time) [][2]string
- func ResetHistory(p paths.Paths, now time.Time, get envnames.Getenv) ([][2]string, error)
- type Area
- type Finding
- type Home
- type ResetPlan
Constants ¶
This section is empty.
Variables ¶
var Areas = []Area{Tool, SSH, Tokens}
Areas lists every area, in the order they are checked.
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 ¶
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 ¶
HistoryPermanent reports whether history.permanent is on, so the history may never be set aside.
func PlanHistoryReset ¶
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 ¶
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 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.
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 ¶
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.