Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Global flock fallback to single-user mode if not enough permissions #1756

Merged
merged 26 commits into from
Jul 6, 2024

Conversation

buhtz
Copy link
Member

@buhtz buhtz commented Jun 7, 2024

The global flock context manager (introduced in #1679) now fall back to single-user mode if not enough permissions available to create an flock file accessible by other users and root. The multi-user mode will be activate later until BIT is started as root for the first time. It will create an flock file accessible by all users. That behavior is relevant for Arch-based systems but not relevant on Debian-based systems because regular users have enough permissions to /run/lock. See the docstring for technical details.

It also fix a bug (introduced with #1679) ignoring the config value of global.use_flock.

Additionally I modified and fixed the Sphinx config to make all necessary information about this behavior available in the generated HTML documentation.

Fix #1743
Fix #1751

@buhtz buhtz added the PR: Waiting for review PR won't be merged until review and approval from a member of the maintenance team. label Jun 7, 2024
@buhtz buhtz self-assigned this Jun 7, 2024
common/flock.py Outdated Show resolved Hide resolved
@willemw12
Copy link

How to test this? Is see "INFO: Lock" and "INFO: Unlock". Is that it?

@buhtz
Copy link
Member Author

buhtz commented Jun 7, 2024

Hello Willem,
thanks for the reply and your efforts to test it. Not having an exception/crash is nice to hear. 😄

How to test this? Is see "INFO: Lock" and "INFO: Unlock". Is that it?

You should make sure to activate Run only one snapshot at a time in the Options tab of the Manage profiles (or Profile Settings) dialog? This need to be done for your users BIT profile and for your roots BIT profile.

Run BIT in terminal with --debug option. If BIT doesn't crash, great! 🤣 On Arch running as user, you should find a message like this in the terminal output.

DEBUG: [common/flock.py:67 GlobalFlock._log] Set flock /run/user/1000/backintime.flock by PID 1234.
...
DEBUG: [common/flock.py:67 GlobalFlock._log] Release flock /run/user/1000/backintime.flock by PID 1234.

If running as root the path is different.

DEBUG: [common/flock.py:67 GlobalFlock._log] Set flock /run/lock/backintime.flock by PID 1234.
...
DEBUG: [common/flock.py:67 GlobalFlock._log] Release flock /run/lock/backintime.flock by PID 1234.

When running again as user, after running it as root, the path should also be /run/lock.

@willemw12
Copy link

Checked it on Arch in Distrobox, as a non-root user. Also does not crash. (Running as root would require more setup.)

@buhtz buhtz added this to the Upcoming release (1.5.0) milestone Jun 27, 2024
@buhtz buhtz added the PR: Merge after creative-break Merge after creative-break (min. 1 week) label Jul 2, 2024
@buhtz
Copy link
Member Author

buhtz commented Jul 2, 2024

I see no strong need for an additional review. Despite myself, two users tested the solution and reported no problems. Because of the time resources I hope it is OK for others if I merge this in the upcoming weekend.

@buhtz buhtz merged commit ba50bf9 into bit-team:dev Jul 6, 2024
@buhtz buhtz deleted the fix/1743flockonarch branch July 6, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Merge after creative-break Merge after creative-break (min. 1 week) PR: Waiting for review PR won't be merged until review and approval from a member of the maintenance team.
Projects
None yet
2 participants