Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 3246

Summary: useradd overwrites existing dot-files by default (without truncating)
Product: [Retired] Red Hat Linux Reporter: dick_streefland
Component: shadow-utilsAssignee: Jay Turner <jturner>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0CC: srevivo
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-06-29 11:52:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description dick_streefland 1999-06-03 17:44:08 UTC
When the useradd command is run to add a new user, existing
"dot" files in the users home directory are overwritten by
default, even though the man page states that these files
are not copied by default. So when you do a fresh install,
mount an existing /home partition, and add the users with
"useradd", a number of important dot-files are blown away. I
would at least expect that a backup copy would be made.

In addition to this, the copy action itself contains a bug.
The destination file is opened without the O_TRUNC flag, so
the file is not truncated on a close. This is easily fixed
by adding the O_TRUNC flag to the open() call in
libmisc/copydir.c:

if ((ofd = open (dst_name, O_WRONLY|O_CREAT|O_TRUNC, 0)) < 0
||

Comment 1 Jay Turner 1999-06-29 11:52:59 UTC
Useradd must be invoked with the -M option in order to not overwrite
the existing config files in the home directory.  The default behavior
for useradd is indeed to overwrite everything in the home directory.