Bug 91682

Summary: useradd ignores -n flag.
Product: Red Hat Enterprise Linux 3 Reporter: Crispian Harris <crispian>
Component: shadow-utilsAssignee: Peter Vrabec <pvrabec>
Status: CLOSED WONTFIX QA Contact: Kevin Baker <kbaker>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: ineilsen, mikem
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 16:12:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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 
behaviour.





Version-Release number of selected component (if applicable):
shadow-utils-4.0.3-6

How reproducible:
Always

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
shadow-utils-4.0.3-20.05.i386
# 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.