mirror of
https://github.com/restic/restic.git
synced 2026-11-23 13:52:39 +00:00
restic init generated and uploaded the key file first and only saved the config afterwards. If two clients ran init against the same empty repository location at nearly the same time, the backend could end up with two key files but only one config file, since backends that reject overwrites let only one of the two config writes succeed. The losing client's key file stayed in the repository without ever belonging to a valid config, so clients picking that key later would fail with a "config or key ... is damaged" error instead of a clear diagnostic. Reorder Repository.init so the config is saved before the key file is uploaded. To make that possible, AddKey no longer generates a random master key internally; callers now supply the master key to encrypt and store. The two other callers of AddKey (key add, key passwd) already had an existing key available and pass that through unchanged.
13 lines
561 B
Plaintext
13 lines
561 B
Plaintext
Bugfix: Fix damaged repository after concurrent `init` on REST backend
|
|
|
|
When two `restic init` runs raced against the same empty repository on
|
|
the REST backend, the repository could end up with a leftover key file
|
|
that did not belong to the stored config. Clients that happened to pick
|
|
that key failed with a "config or key ... is damaged" error.
|
|
|
|
Restic now stores the config file before the key file during `init`, so
|
|
the losing run no longer leaves a key file behind.
|
|
|
|
https://github.com/restic/restic/issues/5717
|
|
https://github.com/restic/restic/pull/21944
|