Skip to content

gh-151519: Check effective gid in _test_all_chown_common group-0 guard#151521

Open
itamaro wants to merge 1 commit into
python:mainfrom
itamaro:gh-151519-test-posix-egid
Open

gh-151519: Check effective gid in _test_all_chown_common group-0 guard#151521
itamaro wants to merge 1 commit into
python:mainfrom
itamaro:gh-151519-test-posix-egid

Conversation

@itamaro

@itamaro itamaro commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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.

…p-0 guard

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.
@itamaro itamaro added tests Tests in the Lib/test dir skip news needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant