Skip to content

Commit 3ffeed0

Browse files
fix(tests): ignore inherited setgid when checking program-cache tmp mode
A setgid TMPDIR parent makes Linux inherit S_ISGID onto mkdir(0o700) tmp dirs. Compare only access bits so the owner-only check stays valid.
1 parent a2fb804 commit 3ffeed0

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎cuda_core/tests/test_program_cache.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,15 +2534,19 @@ def test_program_cache_tmp_dir_created_owner_only(tmp_path):
25342534
"""``tmp`` stages in-flight compiled device code before the atomic rename into
25352535
``entries``, so it must be created owner-only (0o700) regardless of the inherited
25362536
umask. ``root``/``entries`` intentionally inherit the umask to keep deliberately
2537-
shared caches working (PR #2399 review), so only ``tmp`` is asserted."""
2537+
shared caches working (PR #2399 review), so only ``tmp`` is asserted.
2538+
2539+
Compare only the access bits (``& 0o777``). A setgid parent makes Linux inherit
2540+
``S_ISGID`` onto ``tmp``; that bit does not grant access and must not fail the
2541+
owner-only check (issue #3214)."""
25382542
import stat
25392543

25402544
from cuda.core.utils._program_cache._file_stream import FileStreamProgramCache
25412545

25422546
root = tmp_path / "pc"
25432547
FileStreamProgramCache(path=root)
25442548

2545-
mode = stat.S_IMODE(os.stat(root / "tmp").st_mode)
2549+
mode = stat.S_IMODE(os.stat(root / "tmp").st_mode) & 0o777
25462550
assert mode == 0o700, f"tmp has mode {oct(mode)}"
25472551

25482552

@@ -2563,7 +2567,7 @@ def test_program_cache_preexisting_shared_root_used_as_is(tmp_path):
25632567
FileStreamProgramCache(path=root)
25642568

25652569
assert stat.S_IMODE(os.stat(root).st_mode) == 0o777
2566-
assert stat.S_IMODE(os.stat(root / "tmp").st_mode) == 0o700
2570+
assert (stat.S_IMODE(os.stat(root / "tmp").st_mode) & 0o777) == 0o700
25672571

25682572

25692573
@pytest.mark.thread_unsafe(reason="monkeypatches the process-global NVVM fingerprint probe")

0 commit comments

Comments
 (0)