Conversation
…orgbackup#9901 Repository.check() gets a validate argument and passes it to the index rebuild. An object that fails validation is not indexed and each skipped pack byte range counts as an error, which fails a repository-only repair. borg check --repair builds the validator from the key. A full check uses the key it already reads; --repository-only --repair reads it from the manifest and so asks for the passphrase. If the key can not be read, a warning is logged and the rebuild indexes the objects without validation.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10369 +/- ##
==========================================
- Coverage 88.06% 87.99% -0.07%
==========================================
Files 103 103
Lines 18913 18934 +21
Branches 2919 2923 +4
==========================================
+ Hits 16655 16661 +6
- Misses 1565 1579 +14
- Partials 693 694 +1 ☔ View full report in Codecov by Harness. |
Member
|
Guess it would be better to always work with the key and not fall back to keyless. If the passphrase is wrong, key is missing, etc. just abort. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #9901. The repository-level index rebuild in
Repository.check()was the only rebuild that walked the pack object headers without a validator, becauseRepositoryhad no key. It relied on the sha256 pack check done before it, which catches accidental damage but is not authentication. As discussed in #9901, the repository code always runs on the client in borg2, so it can use the key.Changes
Repository.check()takes a newvalidateargument and passes it tobuild_chunkindex_from_repo()for the repair rebuild, together with anon_dropcounter.validate=Nonethe rebuild behaves as before.borg check --repairbuilds the validator withobject_validator(RepoObj(key)):do_checkalready reads before the repository check.--repository-only --repairreads the key from the manifest only. It does not read chunk objects to identify the key type, because it finds those through the chunk index, which may be the corrupt part.borg checkhelp is updated.Behaviour change
borg check --repository-only --repairnow asks for the passphrase. A script that sets onlyBORG_CHECK_I_KNOW_WHAT_I_AM_DOINGand noBORG_PASSPHRASEwill now stop at the passphrase prompt. The key is read before the pack verification starts, so the user is not prompted after a long run. It is read even when the index turns out to be intact and no rebuild is needed.borg check --repository-onlywithout--repairdoes not read the key.Tests
repository_test.py::test_check_repair_rebuild_validates_objects(repository-only and full): a validator rejects one object; the rebuilt index leaves it out, every other object is still readable, and the return value matches the mode.check_cmd_test.py::test_check_repository_only_repair_validates_index_rebuild: an encrypted repository with a byte flipped in one object's metadata slot, the pack stored under the sha256 of its new content so it still passes the pack check, and a corrupt index.check --repository-only --repairexits with 1 and the object is not indexed.check_cmd_test.py::test_check_repository_only_repair_without_key: the same repository with the key made unreadable. The command warns, exits with 0, and indexes the changed object.pytest -n auto -k "not remote and not binary": 2869 passed, 531 skipped.Fixes #9901.