script_kiddie
script_kiddie

Reputation: 1187

rsync SERVER fails

I have set up a rsync server -> /etc/rsyncd.conf

max connection = 5  
log file = /var/log/rsync.log  
[web]  
path = /srv/www/html  
read only = false  
list = yes  
hosts allow = 127.0.0.1  
uid = nobody  
gid = nobody  

[root@localhost www]# ls -l /srv/www/html/  
-rwxrwxrwx. 1 amit amit 8 Apr 28 10:37 index.html  

If I do

$rsync 127.0.0.1::
$web  

then it correctly shows the module name but if I do

$rsync 127.0.0.1::web  
@ERROR: chroot failed  
rsync error: error starting client-server protocol (code 5) at main.c(1503) [receiver=3.0.6]

I dont know why? I am testing working of rsync first on localhost as it failed rsync remotely.

Upvotes: 10

Views: 24892

Answers (3)

aastha
aastha

Reputation: 41

I faced the same issue and noticed the path I was giving in the rsyncd.conf at the server end was wrong. Actual path was path=/usr/share/tomcat/webapps/folder but I was giving path=/usr/share/tomcat6/webapps/folder when I corrected the path is worked. So ensure that your path is correct, has right ownership and permissions.

Upvotes: 2

Paul Podgorsek
Paul Podgorsek

Reputation: 2643

This is likely an SELinux issue, it needs to know that the folder can be used by the rsync daemon. Let's consider an example, to rsync the following folder: /home/myuser/ftp

The following commands need to be run to set the correct SELinux context:

semanage fcontext -a -t rsync_data_t '/home/myuser(/.*)?'
restorecon -Rv '/home/myuser'
setsebool -P rsync_client on

Strangely enough, I noticed the parent folder must be labelled, hence why the labelling is done on /home/myuser instead of /home/myuser/ftp. Restricting to the ftp subfolder is simply done in the rsync daemon configuration.

You can check the SELinux labelling by running:

ls -Z /home/myuser

An interesting article about why combining chroot and SELinux is a good idea: http://blog.siphos.be/2012/04/why-both-chroot-and-selinux/

Upvotes: 0

script_kiddie
script_kiddie

Reputation: 1187

The solution is
In /etc/rsyncd.conf on server add

use chroot = false

I have no clue why its true by default. Got to the solution by luck while browsing rsync documentation. Hope this saves time for others.
Cheers

Upvotes: 21

Related Questions