Skip to content

tempdir hardening fails when filesystem doesn't track ownership #13194

Open
@moroten

Description

@moroten

#8516 verifies that tmpdir and tmp_path etc. are owned by the user. This fails on filesystems that do not track ownership.

In my use case, I am using Buildbarn's FUSE storage on Linux where ownership is always reported as 0. This has the benefit that actions reading the ownership, e.g. tar, will be deterministic.

My workaround is to use the following in my test file:

if __name__ == "__main__":
    sys.exit(pytest.main([
        "--basetemp",
        Path(os.environ["TEST_TMPDIR"]),
        __file__,
    ]))

Would it make sense to allow rootdir_stat.st_uid == 0 in src/_pytest/tmpdir.py? An alternative is to disable the check with an environment variable.

Related issues: #8414 and #10738.

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: tmpdirrelated to the tmpdir builtin plugintype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions