Skip to content

locking: treat a lock object we are not permitted to read as unreadable - #10510

Open
stanleys12 wants to merge 1 commit into
borgbackup:masterfrom
stanleys12:osc/report-a-lock-object-unreadable-due-to-o-fea0
Open

stanleys12 wants to merge 1 commit into
borgbackup:masterfrom
stanleys12:osc/report-a-lock-object-unreadable-due-to-o-fea0

Conversation

@stanleys12

Copy link
Copy Markdown

Description

If a lock object in locks/ was created by another user (e.g. borg run as root, mode 0600), Lock._get_locks() let the PermissionError from store.load() escape and borg crashed with a traceback.

Now a PermissionError / borgstore PermissionDenied on load is handled like any unreadable lock object. It counts as a foreign exclusive lock (fail closed), so acquiring fails with LockTimeout naming locks/<key>, and the existing warning suggests borg break-lock. Nothing new is raised from _get_locks(), so release(), 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 000 file in repo/locks/ and borg repo-list (file backend, non-root user):

  • before: PermissionError: [Errno 13] Permission denied: '.../locks/deadbeef' traceback, rc 2
  • after: Failed to create/acquire the lock ... Repository is locked by: unreadable lock object locks/deadbeef., rc 73

The new test in storelocking_test.py fails on master and passes with this change. It fakes both errors by monkeypatching store.load. I only reproduced the PermissionError path for real (the manual check above), so the borgstore PermissionDenied path 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

  • PR is against master
  • New code has tests and docs where appropriate
  • Tests pass (relevant test subset)
  • Commit messages are clean and reference related issues

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant