Bug 457003 - usermod failed if src and dst are different filesystem
usermod failed if src and dst are different filesystem
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: shadow-utils (Show other bugs)
All Linux
low Severity medium
: rc
: ---
Assigned To: Peter Vrabec
Depends On:
  Show dependency treegraph
Reported: 2008-07-29 01:53 EDT by masanari iida
Modified: 2012-06-20 11:57 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-06-20 11:57:31 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 masanari iida 2008-07-29 01:53:15 EDT
Description of problem:
usermod(8) failed to move contents of user's directory,
if the souce and destination are on different filesystem.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:

Original home directory (source) is on a separate 
filesystem from destination.

# mount | grep /mnt
/dev/cciss/c0d3p1 on /mnt/user0001 type ext3 (rw)
/dev/cciss/c0d3p2 on /mnt/home_file_system type ext3 (rw)

1. # usermod -d /mnt/home_file_system/user0001 -m user0001

Actual results:
usermod: cannot rename directory /mnt/user0001 to /mnt/home_file_system/user0001

Destination Directory NOT exist.
# ll /mnt/home_file_system/user0001
ls: /mnt/home_file_system/user0001: No such file or directory

Original Source Directory IS exist, but all contents are gone.
# ll /mnt/user0001
total 0

Expected results:
User's home directory and its files should be moved without error.

Additional info:
strace shows an error. 

8426  12:09:10.906312 rename("/mnt/user0001", "/mnt/home_file_system/user0001")
= -1 EXDEV (Invalid cross-device link)

EXDEV = old path and new path are not on the same mounted

Even though the EXDEV error happen, still usermod(8) continue
its job such as create destination directory, and delete
user's original file in source directory.

8426  12:09:10.906396 mkdir("/mnt/home_file_system/user0001", 0755) = 0

8426  12:09:10.907246 open("/mnt/user0001/test.txt", O_RDONLY|O_LARGEFILE) = 5
8426  12:09:10.907315 open("/mnt/home_file_system/user0001/test.txt",

8426  12:09:10.907563 read(5, "abc\n", 1024) = 4
8426  12:09:10.907632 write(6, "abc\n", 4) = 4
8426  12:09:10.908445 unlink("/mnt/user0001/test.txt") = 0

And at last, delete destination directory!

8426  12:09:10.909217 unlink("/mnt/home_file_system/user0001/test.txt") = 0
8426  12:09:10.909421 rmdir("/mnt/home_file_system/user0001") = 0

If this is a bug, it need to be fixed.
If this is a limitation, so you should document in man that
usermod(8) can not support between 2 different filesystem.
Comment 1 Peter Vrabec 2010-07-23 09:34:30 EDT
I can't reproduce this problem. :(

There are two different filesystems
# stat --format='%d\n' /home/foo /mnt/test/lost+found/

# usermod -d /mnt/test/foo -m foo

# stat /home/foo
stat: cannot stat `/home/foo': No such file or directory
# ls -a /mnt/test/foo/
.  ..  .bash_logout  .bash_profile  .bashrc  .canna  .emacs  .gtkrc  .kde  .xemacs  .zshrc

# rpm -q shadow-utils

strace error EXDEV is OK.
Comment 2 Jiri Pallich 2012-06-20 11:57:31 EDT
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.