Bug 91682 - useradd ignores -n flag.
useradd ignores -n flag.
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: shadow-utils (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Peter Vrabec
Kevin Baker
Depends On:
  Show dependency treegraph
Reported: 2003-05-27 02:41 EDT by Crispian Harris
Modified: 2014-12-01 18:08 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-06-20 12:12:15 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Crispian Harris 2003-05-27 02:41:46 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.6 (X11; Linux i686; U;) Gecko/20020916

Description of problem:
Useradd will not add a user to the system when using the -n flag if
a group named after the user exists in /etc/group.

On line 1817 of useradd.c, useradd performs a check to see if there
is a group which corresponds to the username specified and exits 
if there is one. In the case where there is a group named after 
the user, -n is specified, and the default group (in 
/etc/default/useradd) is something else (say, groupid 100), useradd 
will not add the user and exits with the error: 

useradd: group <whatever> exists - if you want to add this user to that group,
use -g.

Since we're using the -n flag, this shouldn't be relevant. This
upsets some automated scripts, which are expecting the documented 

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Add a group named 'foobar' (with gid=200 for example)
2. Add the line 'GROUP=80' to /etc/default/useradd (add a gid of 80 if there
isn't one)
3. Try to add a user with the default gid of 80 to the system:
   useradd -n foobar


Actual Results:  Got the error message:

useradd: group foobar exists - if you want to add this user to that group, use -g.

Expected Results:  User should have been added with default group 80.

Additional info:

This error was not present in 7.3 (shadow-utils-20000902-7)
Comment 1 Mike McLean 2004-09-07 14:56:21 EDT
This problem is present in RHEL3

# rpm -q shadow-utils
# groupadd foobar
# useradd -n foobar
useradd: group foobar exists - if you want to add this user to that
group, use -g.
# groupdel foobar
# user add -n foobar     #now it succeeds
# groups foobar
foobar : users
Comment 5 Jiri Pallich 2012-06-20 12:12:15 EDT
Thank you for submitting this issue for consideration in Red Hat Enterprise Linux. The release for which you requested us to review is now End of Life. 
Please See https://access.redhat.com/support/policy/updates/errata/

If you would like Red Hat to re-consider your feature request for an active release, please re-open the request via appropriate support channels and provide additional supporting details about the importance of this issue.

Note You need to log in before you can comment on or make changes to this bug.