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

linux get_runtime_dir() result for root #7640

Closed
ThomasWaldmann opened this issue Jun 10, 2023 · 8 comments
Closed

linux get_runtime_dir() result for root #7640

ThomasWaldmann opened this issue Jun 10, 2023 · 8 comments

Comments

@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented Jun 10, 2023

getting permission denied when unit tests run on ubuntu lunar64 when dealing with /run/user/0.

this is a bug in platformdirs, see: tox-dev/platformdirs#188

workaround: use BORG_RUNTIME_DIR to override

@priand1
Copy link

priand1 commented Jun 18, 2023

I am not sure if the error I am encountering is the same as this one, but to me it seems not to be the case.
I am on openSUSE Tumbleweed trying to build 2.0.0b6 with osc and during the tests I get the following error:
[25s] build/lib.linux-x86_64-cpython-311/borg/testsuite/helpers.py::test_get_runtime_dir FAILED [ 38%]
name = '/run/user', mode = 511, exist_ok = True
[ 25s]
[ 25s] > ???
[ 25s] E PermissionError: [Errno 13] Permission denied: '/run/user'

I can make borgbackup pass all tests during build by changing the permissions for /run/usr to writable for everyone.

borgbackup-test-failure.txt

Please let me know if you need more info.
Thank you!

@ThomasWaldmann
Copy link
Member Author

@priand1 It's not the same as you did not run borg as root.

In your case, I suspect that /run/user/399 should already exist (guess that should be created at login time, when user 399 logs in, so it can be used by any process running under that uid). Because it did not exist already, borg tried to create it, but missed permission to create the 399 directory under /run/user.

@priand1
Copy link

priand1 commented Jun 25, 2023

@ThomasWaldmann Thanks for your answer.
But i am still unsure what conclusion I should/could draw from it, though.

Is it that I should
a) open a new issue here against borgbackup
or
b) rather open a bug against openSUSE build service

Please let me know. Thank you.

@ThomasWaldmann
Copy link
Member Author

ThomasWaldmann commented Jun 25, 2023

@priand1 The traceback you got is not completely clear, so what I said was an educated guess rather.

But I'ld say something is wrong in that environment, either there should be permissions to create that /run/user/399 dir for uid 399 or that directory should already exist. Also, there of course need to be permissions to create files and dirs inside that dir.

So you maybe could write a much simpler python program and push it to that build service:

#!/usr/bin/env python3
import os
uid = os.getuid()
run_dir = f"/run/user/{uid}/subdir"
os.makedirs(run_dir, exist_ok=True)
assert os.path.exists(run_dir)

If that raises an exception, file a bug against the build service or OS.

@priand1
Copy link

priand1 commented Jun 25, 2023

@ThomasWaldmann Thank you!

@ThomasWaldmann
Copy link
Member Author

Still happens with current code / packages.

@ThomasWaldmann
Copy link
Member Author

ThomasWaldmann commented Aug 27, 2023

The permission denied error when it tries to create /run/user/0 is due to fakeroot - it works with sudo.

To avoid this, get_runtime_dir (and other get_*_dir) could get a create=True flag and the tests could call it with create=False.

See #7778.

@ThomasWaldmann
Copy link
Member Author

Just tested the lunar64 VM again and the permission denied is gone, thus closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants