From 8473ece90e53040931c880bcbff623f1a5c037cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Wed, 25 Oct 2023 17:39:04 +0100 Subject: [PATCH] test-systemd-tmpfiles: skip when /tmp has unexpected ownership MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é --- test/test-systemd-tmpfiles.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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))