redhat-cip / edeploy

Linux systems provisioning and updating made easy
Apache License 2.0
92 stars 38 forks source link

build/mngids.py: Fix bad assumption about default user group #197

Closed morucci closed 9 years ago

morucci commented 9 years ago

The previous code make a bad assumption where when a useradd is performed without the gid option useradd will create the group for the user with t a gid similar to the uid. This is wrong.

This patch allow a workflow such as (seen in one rpm package): /usr/sbin/useradd -u 29 -d /var/lib/nfs rpcuser || true /usr/sbin/groupadd -g 29 rpcuser || true where the second command will fail because a default group has been created by useradd.

In this patch when useradd is called without -g or --gid we call groupadd to create the rpcuser group with the right uid according to ids.table just before calling useradd.real with the --gid option. When we call groupadd internaly we do not raise an error if the group already exists to allow a workflow such as: /usr/sbin/groupadd -g 29 rpcuser || true /usr/sbin/useradd -u 29 -d /var/lib/nfs rpcuser || true where the group.