mirror of
https://github.com/cloudflare/redoctober.git
synced 2026-01-05 13:07:10 +00:00
Add CLI support for restore endpoint.
+ Add the relevant parts to the command line tool and the client package. + Small improvements to cryptor's restore function: + Don't try to restore if the store is already active. + Flush the persistence key cache once the restoration occurs. + The redoctober program now explicitly mentions that a config file is invalid when that's the case.
This commit is contained in:
@@ -742,6 +742,11 @@ var ErrRestoreDelegations = errors.New("cryptor: need more delegations")
|
||||
// enough delegations are present to restore the cache, the current
|
||||
// Red October key cache is replaced with the persisted one.
|
||||
func (c *Cryptor) Restore(name, password string, uses int, slot, durationString string) error {
|
||||
// If the persistence store is already active, don't proceed.
|
||||
if st := c.persist.Status(); st != nil && st.State == persist.Active {
|
||||
return nil
|
||||
}
|
||||
|
||||
record, ok := c.records.GetRecord(name)
|
||||
if !ok {
|
||||
return errors.New("Missing user on disk")
|
||||
@@ -774,6 +779,7 @@ func (c *Cryptor) Restore(name, password string, uses int, slot, durationString
|
||||
|
||||
c.cache = keycache.NewFrom(uk)
|
||||
c.persist.Persist()
|
||||
c.persist.Cache().Flush()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user