mirror of
https://github.com/systemd/systemd.git
synced 2024-11-23 02:03:37 +08: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>
This commit is contained in:
parent
6aa77f9284
commit
8473ece90e
@ -31,6 +31,14 @@ except AttributeError:
|
||||
exe_with_args = sys.argv[1:]
|
||||
temp_dir = tempfile.TemporaryDirectory(prefix='test-systemd-tmpfiles.')
|
||||
|
||||
# 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…
Reference in New Issue
Block a user