Documentation
¶
Overview ¶
Package keyfile writes a newly generated key to disk so it survives a crash.
The secrets key and the API token key are each created once, on first start, and everything encrypted or digested afterwards depends on them. A key that was linked into place but never flushed can come back from a power loss as an empty file, while the secrets encrypted under it are already committed to Postgres and can no longer be read.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
Create writes key to path, 0600, and flushes it and its directory entry to disk before returning.
The key is written beside path and linked into place, which fails with an error matching os.ErrExist if a file is already there. Several replicas sharing one volume start at once, and two that each wrote their own key would each use one the other cannot; the one that loses the link reads the winner's instead (issue #72).
func Replace ¶ added in v0.17.0
Replace writes key to path, 0600, in place of whatever is there, flushed as Create's is. A host joining a cluster takes the cluster's keys in place of the ones it made at its own first start (R-415); renamed into place, so a crash leaves the old key or the new one, never half of either.
Types ¶
This section is empty.