user/group add/mod utilities in the shadow package cannot cope with groups containing large numbers of members
The user/group add/modify utilities provided by the shadow package cannot handle groups with more than ~16 members. This appears to be due to the way the getX code deals with such groups: it allocates a small buffer, then expects the c library to return an error and set errno to ERANGE, to which it then reallocates/enlarges the buffer and tries again. This is done by glibc, but not by musl, and thus on alpine such groups have issues.
Steps to reproduce:
- run alpine (edge tested)
- install the shadow package
- create more than 16 users
- attempt to add those users to a single group (or modify their supplemental group membership to include that group)
Output shown below:
/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.6.0
PRETTY_NAME="Alpine Linux v3.6"
HOME_URL="http://alpinelinux.org"
BUG_REPORT_URL="http://bugs.alpinelinux.org"
/ # getent group abuild
abuild:x:300
/ # for i in `seq 1 16`; do echo user${i}: `useradd -U -p '*' -M -G abuild user$
{i}`;done
user1:
user2:
user3:
user4:
user5:
user6:
user7:
user8:
user9:
user10:
user11:
user12:
user13:
user14:
user15:
useradd: group 'abuild' does not exist
user16:
/ # getent group abuild
abuild:x:300:user1,user2,user3,user4,user5,user6,user7,user8,user9,user10,user11,user12,user13,user14,user15
/ # usermod -aG abuild user16
usermod: group 'abuild' does not exist
(from redmine: issue id 7390, created on 2017-06-06, closed on 2018-09-11)
- Changesets:
- Revision 25c230ba by Timo Teräs on 2017-07-05T11:53:48Z:
main/musl: cherry-pick upstream fixes
fixes #7390