HomeFreeBSD

chroot: don't setgroups() without -G having been specified

Description

chroot: don't setgroups() without -G having been specified

We previously would not have setgroups() at all, but now we would drop
our supplementary groups every time. This broke chroot -n, probably
among other things. We need tests here, but lets unbreak things first.

A future change may try to setgroups(2) when -u is specified in addition
to -G, so predicate the call on gidlist and don't populate that without
a grouplist.

PR: 288751
Fixes: 48fd05999b0f ("chroot: don't clobber the egid [...]")

Details

Provenance
kevansAuthored on Aug 12 2025, 12:14 PM
Parents
rG0312f80349ee: udp: use appropriate error counters
Branches
Unknown
Tags
Unknown