Bug 3246 - useradd overwrites existing dot-files by default (without truncating)
useradd overwrites existing dot-files by default (without truncating)
Product: Red Hat Linux
Classification: Retired
Component: shadow-utils (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jay Turner
Depends On:
  Show dependency treegraph
Reported: 1999-06-03 13:44 EDT by dick_streefland
Modified: 2015-01-07 18:37 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 1999-06-29 07:52:50 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 dick_streefland 1999-06-03 13:44:08 EDT
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

if ((ofd = open (dst_name, O_WRONLY|O_CREAT|O_TRUNC, 0)) < 0
Comment 1 Jay Turner 1999-06-29 07:52:59 EDT
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.

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