Repository navigation
security: same local repo dir via another path is not a relocation, fixes #8188 - #10578
Open
ThomasWaldmann wants to merge 1 commit into
Open
ThomasWaldmann wants to merge 1 commit into
ThomasWaldmann wants to merge 1 commit into
Conversation
…ixes borgbackup#8188 The "repository was previously located at" check compared path strings only, so reaching the same local repository directory via a symlink, a bind mount or a different letter case on a case-insensitive filesystem looked like a relocation. Answering yes rewrote the stored location, so alternating between the paths kept triggering the prompt (breaking e.g. unattended prune). If the strings differ, but both are local paths referring to the same existing directory (same st_dev/st_ino, st_ino != 0), do not warn. The stored location and all displayed paths stay as they were. Remote locations are not affected, and a real move/rename (old path gone) still triggers the warning. Backport of borgbackup#10516. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.4-maint #10578 +/- ##
=============================================
+ Coverage 82.11% 82.13% +0.01%
=============================================
Files 38 38
Lines 11485 11496 +11
Branches 1810 1812 +2
=============================================
+ Hits 9431 9442 +11
Misses 1468 1468
Partials 586 586 ☔ View full report in Codecov by Harness. |
This branch has not been deployed
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.
Backport of #10516 to 1.4-maint. Fixes #8188.
The "repository was previously located at" check in
SecurityManager.assert_location_matches()(incache.pyon 1.4) compared path strings only. So reaching the same local repository directory via a different path looked like a relocation:bar -> foo)FOOvsfooon macOS APFS)Answering "yes" rewrote the stored location, so alternating between the paths kept re-triggering the prompt, which breaks unattended runs (e.g. prune).
Change
If the path strings differ, borg now also checks whether both are local paths referring to the same existing directory (
os.stat+os.path.samestat). If they do, there is no warning.file) repositories with an absolute previous path.ssh://locations are never affected.st_ino == 0are never treated as "same".Differences from the master PR: the code lives in
cache.py, and the tests are in the unittest-styleArchiverTestCaseintestsuite/archiver.py(skipped for the remote variant). The NFC/NFD normalization from #2913 is not on 1.4-maint, so this change does not include it.Tests
test_repository_access_via_symlink: repo path, then symlink, then repo path again, withBORG_RELOCATED_REPO_ACCESS_IS_OK=no. It expects no abort and an unchanged stored location. It fails without the fix.test_repository_previously_remote: a previously storedssh://location still triggers the abort.test_repository_movestill covers a real rename.The FAQ entry "How do I rename a repository?" got one sentence about this.
🤖 Generated with Claude Code