From: Daniel P. Berrangé Date: Wed, 25 Oct 2023 16:39:04 +0000 (+0100) Subject: test-systemd-tmpfiles: skip when /tmp has unexpected ownership X-Git-Tag: v255-rc1~123^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8473ece90e53040931c880bcbff623f1a5c037cd;p=thirdparty%2Fsystemd.git 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é --- diff --git a/test/test-systemd-tmpfiles.py b/test/test-systemd-tmpfiles.py index 77ef53b9839..37a5e9ef3e4 100755 --- a/test/test-systemd-tmpfiles.py +++ b/test/test-systemd-tmpfiles.py @@ -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))