mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-13 12:58:20 +03:00
test-systemd-tmpfiles: skip when /tmp has unexpected ownership
The systemd-tmpfiles binary will report a fatal error if /tmp is not owned either by root, or by the current user: Detected unsafe path transition /tmp (owned by nobody) → /tmp/test-systemd-tmpfiles.a8qc6n18 (owned by berrange) during canonicalization of tmp/test-systemd-tmpfiles.a8qc6n18/test-content.7chd7rdi When doing development inside a 'toolbox' container (which is required on a Fedora SilverBlue distro), /tmp is owned by 'nobody', because it has been passed through from the host and host UID 0 gets mapped to UID 65536 by usernamespaces. This triggers the unsafe path transition error message. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> (cherry picked from commit 8473ece90e53040931c880bcbff623f1a5c037cd) (cherry picked from commit c7482035e3cefbfae2a1cc4b4529ebb705d67531) (cherry picked from commit 95cbb9e857dc9dec07041d9d85a09928d44107c1)
This commit is contained in:
parent
7382074f23
commit
a26ba37b9d
@ -29,6 +29,14 @@ except AttributeError:
|
||||
|
||||
exe_with_args = sys.argv[1:]
|
||||
|
||||
# If /tmp isn't owned by either 'root' or the current user
|
||||
# systemd-tmpfiles will exit with "Detected unsafe path transition"
|
||||
# breaking this test
|
||||
tmpowner = os.stat("/tmp").st_uid
|
||||
if tmpowner != 0 and tmpowner != os.getuid():
|
||||
print("Skip: /tmp is not owned by 'root' or current user")
|
||||
sys.exit(EXIT_TEST_SKIP)
|
||||
|
||||
def test_line(line, *, user, returncode=EX_DATAERR, extra={}):
|
||||
args = ['--user'] if user else []
|
||||
print('Running {} on {!r}'.format(' '.join(exe_with_args + args), line))
|
||||
|
Loading…
x
Reference in New Issue
Block a user