Commit 01489b0
test_posix: fix flaky chown-to-gid-0 assertion under gid 0
Summary:
`PosixTester._test_all_chown_common` asserts that chowning a file's group to
gid 0 raises OSError when the process is "unprivileged". It gated that on
`0 not in os.getgroups()`, but group membership for chown also includes the
process's effective gid, which getgroups() does not report. In sandboxes /
user namespaces that run with gid 0 and a non-zero uid, chgrp-to-0 therefore
succeeds and the assertion fails ("OSError not raised by {chown,fchown,lchown}")
while the owner-to-0 assertions (which need CAP_CHOWN) still correctly raise.
Also require `os.getegid() != 0` before asserting the failure.
<!-- pyimport-metadata:begin -->
This diff adds a patch to the `third-party/python/3.14` Meta-internal fork.
test_posix: chgrp-to-0 membership also includes the effective gid; avoids spurious failure when the sandbox runs with gid 0
Reviewed By: Yhg1s
Differential Revision: D108567108
fbshipit-source-id: 25345fc871b9e834af3241a94afed9cf85dcb9871 parent e0e4251 commit 01489b0
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
838 | 838 | | |
839 | 839 | | |
840 | 840 | | |
841 | | - | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
842 | 848 | | |
843 | 849 | | |
844 | 850 | | |
| |||
0 commit comments