useradd is not looking for --gid in --root

Bug #1785389 reported by Simon Levesque
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
shadow (Ubuntu)
New
Undecided
Unassigned

Bug Description

Application: /usr/sbin/useradd

Doing:
 THE_ID=70000
 THE_NAME=aaaaa
 groupadd --gid $THE_ID $THE_NAME
 useradd --uid $THE_ID --gid $THE_ID --home-dir /home/$THE_NAME --create-home $THE_NAME

is working fine, but when specifying a --root, the provided --gid is not checked in the group file in the --root folder. Steps:

 BASE_FOLDER=$(mktemp -d)
 cd $BASE_FOLDER
 THE_ID=70000
 THE_NAME=aaaaa
 mkdir etc home
 touch etc/group etc/passwd etc/shadow
 groupadd --root $BASE_FOLDER --gid $THE_ID $THE_NAME
 useradd --root $BASE_FOLDER --uid $THE_ID --gid $THE_ID --home-dir /home/$THE_NAME --create-home $THE_NAME

Getting error
  useradd: group '70000' does not exist

checking the group file, the group exists:
grep aaaaa $BASE_FOLDER/etc/group
  aaaaa:x:70000:

------

Description: Ubuntu 18.04.1 LTS
Release: 18.04

passwd:
  Installed: 1:4.5-1ubuntu1
  Candidate: 1:4.5-1ubuntu1
  Version table:
 *** 1:4.5-1ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.