Bug 584906

Summary: rdist deletes destination directory tree when only one source file is specified
Product: Red Hat Enterprise Linux 4 Reporter: Casey Dahlin <cdahlin>
Component: rdistAssignee: Vojtech Vitek <vvitek>
Status: CLOSED WONTFIX QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: medium Docs Contact:
Priority: low    
Version: 4.8CC: hripps, ovasik, plyons, rvokal, tao, vanhoof
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 663297 663308 (view as bug list) Environment:
Last Closed: 2010-12-15 11:30:06 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:
Bug Depends On:    
Bug Blocks: 663297, 663308    

Description Casey Dahlin 2010-04-22 17:08:57 UTC
Description of problem:
Destination machine, # mkdir -p /rdist/test

execte rdist to copy a single file to the destination.

[root@dhcp210-29 rdist]# rdist -o noverify,noremove  -P /usr/bin/ssh -p /usr/sbin/rdistd -c LICENSE 10.65.210.54:/rdist/test
10.65.210.54: updating host 10.65.210.54
10.65.210.54: LICENSE: updating
10.65.210.54: dhcp210-54: /rdist/test: removed
10.65.210.54: updating of 10.65.210.54 finished
[root@dhcp210-29 rdist]#

Destination machine,

[root@dhcp210-54 rdist]# ls -l /rdist/
total 8
-rw-r--r--  1 root root 6279 Apr 23  2010 test
[root@dhcp210-54 rdist]## file test
test: ASCII English text
[root@dhcp210-54 rdist]#
As you can see the destination directory got replaced with a file with the contents of LICENSE file.

The above behavior is normal. (if there is no trailing / then rdist treat the last part as the file name).

Now execute the same commands with trailing /  (removed the file from destination box, created the directory /rdist/test)

[root@dhcp210-29 rdist]# rdist -o noverify,noremove  -P /usr/bin/ssh -p /usr/sbin/rdistd -c LICENSE 10.65.210.54:/rdist/test/
10.65.210.54: updating host 10.65.210.54
10.65.210.54: LICENSE: updating
10.65.210.54: dhcp210-54: /rdist/test//rdistFlfP9L: removed
10.65.210.54: dhcp210-54: /rdist/test/: removed
10.65.210.54: dhcp210-54: REMOTE ERROR: /rdist/test/rdistFlfP9L -> /rdist/test/: rename failed: No such file or directory
10.65.210.54: updating of 10.65.210.54 finished
[root@dhcp210-29 rdist]#

Note the trailing / on /rdist/test/), This time rdist removes the destination directory /rdist/test.

The removal of /rdist/test directory is a bug, if it's replaced with the content of LICENSE file (as it does when we execute without trailing /) then it's acceptable.

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

How reproducible:
Always

Additional info:
Bug appeared in AS 2.1 and RHEL 3. Bugzilla 108486. The bug was reported as being fixed. Hence the regression keyword.

Comment 5 Vojtech Vitek 2010-12-14 16:13:25 UTC
There are two test cases as Casey already mentioned:

1) Without a trailing slash '/':

$ cd; touch test-file; mkdir test
$ rdist -o noverify,noremove  -P /usr/bin/ssh -p /usr/sbin/rdistd -c test-file 127.0.0.1:/home/vvitek/test
127.0.0.1: updating host 127.0.0.1
vvitek.0.1's password: 
127.0.0.1: test-file: updating
127.0.0.1: dhcp-*: /home/vvitek/test: removed
127.0.0.1: updating of 127.0.0.1 finished

This can be considered as expected behaviour (*).
Rdist just replaced the destination directory with the new file.


2) With a trailing slash '/':

$ cd; touch test-file; mkdir test
$ rdist -o noverify,noremove -P /usr/bin/ssh -p /usr/sbin/rdistd -c test-file 127.0.0.1:/home/vvitek/test/
127.0.0.1: updating host 127.0.0.1
vvitek.0.1's password: 
127.0.0.1: test-file: updating
127.0.0.1: dhcp-*: /home/vvitek/test//rdist35JjYB: removed
127.0.0.1: dhcp-*: /home/vvitek/test/: removed
127.0.0.1: dhcp-*: REMOTE ERROR: /home/vvitek/test/rdist35JjYB -> /home/vvitek/test/: rename failed: No such file or directory
127.0.0.1: updating of 127.0.0.1 finished

This is bug even if (*) was expected behaviour.
Rdist just _deleted_ the destination directory but was _not able to create_ the new file.


(*): Rdist removes destination directory with a file without any check.
Other programs, such as rsync, cp, scp and mv never do this. They always check if the destination path wasn't an existing directory (even if one provides trailing slash or not) - and if it was existing directory, they creates new file inside that directory.

Comment 7 RHEL Program Management 2010-12-14 19:18:36 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.