]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-151519: Check effective gid in `_test_all_chown_common` group-0 guard (#151521)
authorItamar Oren <itamarost@gmail.com>
Tue, 16 Jun 2026 16:05:21 +0000 (09:05 -0700)
committerGitHub <noreply@github.com>
Tue, 16 Jun 2026 16:05:21 +0000 (18:05 +0200)
commit2ce260033b457a0ad2c9767a1d9902bef5a30b0e
tree5c5aed54febaf39bbe1818d4b8163854974b4e46
parent0777a58d8012bbdd0d72654b56f9112686ae6ff0
gh-151519: Check effective gid in `_test_all_chown_common` group-0 guard (#151521)

The guard that skips the "chown to gid 0 should fail" assertion used
only `os.getgroups()` (supplementary groups). The kernel also accepts
the effective/filesystem gid for chown, so when a process runs with
egid 0 and a non-zero uid (common in containers and user namespaces),
chown(-1, 0) succeeds and the assertion spuriously fails.

Add an `os.getegid() != 0` check alongside the existing
`0 not in os.getgroups()` guard.
Lib/test/test_os/test_posix.py