Subject: Useradd, usermod do not use the target to read groups from when using the -R parameter

From: Olliver Schinagl <[email-masked]>
Date: Mon, 20 Jul 2015 10:12:18 +0200

Hi list,

I'm trying to generate a rootfs and am using a script to add users, 
groups etc. I first add a group via groupadd -R ${ROOTFS_TARGET} 
somegroup which works fine.
Using useradd with the -R parameter, to add a user also works as 
expected, until i try to add the -a -G somegroup options. Using usermod 
after creating the group and doing -a -G somegroup identically fails 
informing us there is no such group, somegroup.

It appears both usermod and useradd use the local /etc/group rather then 
what is supplied via the -R parameter. A workaround for now, is to use 
chroot directly, chroot ${TARGET} usermod -a -G somegroup someuser, but 
that only works if coreutils (or busybox (without useradd/usermod)) are 
already installed on the target, which may not be there (yet/at all).

Am I doing something wrong or is this indeed a bug in the coreutils?

I'm using debian jessie's 8.23-4 on amd64

Olliver

-- 
Met vriendelijke groeten, Kind regards, 与亲切的问候

Olliver Schinagl
Research & Development
Ultimaker B.V.

-- 

IMAGINE IT >> MAKE IT

Meet us online at Twitter <http://twitter.com/ultimaker>, Facebook 
<http://facebook.com/ultimaker>, Google+ <http://google.com/+Ultimaker>

www.ultimaker.com