Bug 91682 - useradd ignores -n flag.
Summary: useradd ignores -n flag.
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: shadow-utils (Show other bugs)
(Show other bugs)
Version: 3.0
Hardware: i386 Linux
Target Milestone: ---
Assignee: Peter Vrabec
QA Contact: Kevin Baker
Depends On:
TreeView+ depends on / blocked
Reported: 2003-05-27 06:41 UTC by Crispian Harris
Modified: 2014-12-01 23:08 UTC (History)
2 users (show)

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

Attachments (Terms of Use)

Description Crispian Harris 2003-05-27 06:41:46 UTC
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 18:56:21 UTC
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 16:12:15 UTC
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.