Bug 457003

Summary: usermod failed if src and dst are different filesystem
Product: Red Hat Enterprise Linux 4 Reporter: masanari iida <masanari_iida>
Component: shadow-utilsAssignee: Peter Vrabec <pvrabec>
Status: CLOSED WONTFIX QA Contact:
Severity: medium Docs Contact:
Priority: low    
Version: 4.4   
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 15:57:31 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 masanari iida 2008-07-29 05:53:15 UTC
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):
shadow-utils-4.0.3-60.RHEL4

How reproducible:
Always

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

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",
O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0) = 6

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 13:34:30 UTC
I can't reproduce this problem. :(

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

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

-----------
strace error EXDEV is OK.

Comment 2 Jiri Pallich 2012-06-20 15:57:31 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.