Inconsistent getent group output with empty groups
Package Information
- Package name: musl
- Package version: musl-1.2.5-r0
- Alpine version: 3.20.3
- Alpine architecture: x86_64
Summary
When a group doesn't contain any members, getent group omits the trailing colon in the output, resulting in only three fields instead of the expected four. This behavior differs from systems using glibc, where getent group consistently includes the trailing colon, even for empty groups.
Steps to reproduce
Alpine Linux (musl-utils):
$ getent group test
test:!:1000 <- Missing the last colon
$ getent group root
root:x:0:root <- Colon present when members exist
glibc-based System:
$ getent group test
test:!:1000: <- Colon present even with no members
Impact
This inconsistency causes issues when parsing the output of getent group with tools like Python's jc library, which expect a consistent number of fields.
Note: I opened an issue upstream and they redirected me here.
Edited by Iker Pedrosa