Bug 3246 - useradd overwrites existing dot-files by default (without truncating)
Summary: useradd overwrites existing dot-files by default (without truncating)
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: shadow-utils
Version: 6.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jay Turner
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-06-03 17:44 UTC by dick_streefland
Modified: 2015-01-07 23:37 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 1999-06-29 11:52:50 UTC
Embargoed:


Attachments (Terms of Use)

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.


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