Skip to content

dbus-sysdeps-unix: Handle empty supplementary group list

cptpcrd requested to merge cptpcrd/dbus:empty-group-list into master

It is valid for getsockopt(SO_PEERGROUPS) to return len=0; that indicates the process has no supplementary groups. Rather than failing, simply use the returned empty list (and add the primary GID to it).

Without this change, calling GetConnectionCredentials on a bus name owned by a process with no supplementary groups does not return the UnixGroupIDs field, even though it is easy to determine that the process only has one GID (the primary GID).

Note: I originally switched the check from <= 0 to < 0, but the compiler complained - on Linux, socklen_t is an unsigned integer and cannot be negative.

Merge request reports