linux get_runtime_dir() result for root
getting permission denied when unit tests run on ubuntu lunar64 when dealing with /run/user/0.
this is a bug in platformdirs, see: platformdirs/platformdirs#188
workaround: use BORG_RUNTIME_DIR to override
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.
Please let me know if you need more info. Thank you!
@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.
@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.
@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.
@ThomasWaldmann Thank you!
Still happens with current code / packages.
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.
Just tested the lunar64 VM again and the permission denied is gone, thus closing this.