Repository navigation
locking: treat a lock object we are not permitted to read as unreadable - #10510
Open
stanleys12 wants to merge 1 commit into
Open
stanleys12 wants to merge 1 commit into
stanleys12 wants to merge 1 commit into
Conversation
A lock object created by another user (e.g. by borg running as root) made borg crash with a PermissionError traceback. Treat it like any other unreadable lock object: it blocks us (fail closed), is named in the error message and can be removed with borg break-lock.
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.
Description
If a lock object in
locks/was created by another user (e.g. borg run as root, mode 0600),Lock._get_locks()let thePermissionErrorfromstore.load()escape and borg crashed with a traceback.Now a
PermissionError/ borgstorePermissionDeniedon load is handled like any unreadable lock object. It counts as a foreign exclusive lock (fail closed), so acquiring fails withLockTimeoutnaminglocks/<key>, and the existing warning suggestsborg break-lock. Nothing new is raised from_get_locks(), sorelease(),break_lock()and the rechecks after creating our own lock work as before. Lock file modes are not changed.I checked by hand with a
chmod 000file inrepo/locks/andborg repo-list(file backend, non-root user):PermissionError: [Errno 13] Permission denied: '.../locks/deadbeef'traceback, rc 2Failed to create/acquire the lock ... Repository is locked by: unreadable lock object locks/deadbeef., rc 73The new test in
storelocking_test.pyfails on master and passes with this change. It fakes both errors by monkeypatchingstore.load. I only reproduced thePermissionErrorpath for real (the manual check above), so the borgstorePermissionDeniedpath is covered by the simulated test only.Related to #10465
AI assistance: I used an AI coding assistant while working on this. I reviewed, tested and adjusted the change myself and take responsibility for it.
Checklist
master