Rsync chdir failed error

I have a D-Link DNS-320 and I've installed FFP and I'm trying to get rsync running on it. So far I've got the daemon up and running and I've defined a module in my rsyncd.conf like so: max conne...

I have a D-Link DNS-320 and I’ve installed FFP and I’m trying to get rsync running on it.

So far I’ve got the daemon up and running and I’ve defined a module in my rsyncd.conf like so:

max connections = 10
secrets file = /ffp/etc/rsyncd.secret

use chroot = false
read only = no
list = true
strict modes = false
#hosts deny = *
timeout = 600
dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz *.mkv *.avi *.mpg *.jpg *.rar
pid file = /var/run/rsyncd.pid
reverse lookup = no

[root]
hosts allow = *
read only = false
gid = allaccount
uid = nobody
auth users = greg
path = /mnt/HD/HD_a2/rsync
comment = Fish
list = yes

/mnt/HD/HD_a2 is the internal disk and /mnt/HD/HD_a2/rsync exists:

root@nas:/mnt/HD/HD_a2/rsync# pwd  
/mnt/HD/HD_a2/rsync

with the following permissions:

root@nas:/mnt/HD/HD_a2# ls -la
total 154589
drwxrwxrwx 23 root   root            4096 Oct  2 19:44 .
drwxr-xr-x  3 root   root            1024 Oct  2 17:20 ..
drwxrwxrwx  4 root   root            4096 Dec 29  2013 Ajaxpf
drwxrwxrwx 21 nobody allaccount      4096 Oct  2 15:45 NAS
dr-xr-xr-x  4 root   root            4096 Sep 24 17:45 Public
drwxr-xr-x  3 root   root            4096 Sep 24 17:45 Users
drwxr-xr-x 17 root   root            4096 Aug 27 14:11 ffp
-rw-r--r--  1 root   root            1117 Oct  2 17:20 ffp.log
-rwxr-xr-x  1 root   root            1942 Sep 23 17:29 fun_plug
drwxr-xr-x  2 root   root            4096 Jul 15  2012 logs
drwxrwxrwx  2 nobody allaccount      4096 Oct  2 21:09 rsync

I have the user greg defined in my rsync.secret file and I can successfully connect from my (Windows) client and list the module:

C:Batchrsync> rsync greg@nas::  
root            Fish

However; When I try to send a file I get @ERROR: chdir failed:

C:Batchrsync> rsync -vvvv SRC test.txt greg@nas::root/test.txt  
opening tcp connection to nas port 873  
Connected to nas (192.168.10.5)  
note: iconv_open("UTF-8", "UTF-8") succeeded.  
sending daemon args: --server -vvvve.Lsf . root/test.txt  
@ERROR: chdir failed  
[sender] _exit_cleanup(code=5, file=/usr/src/ports/rsync/rsync-3.0.9-1/src/rsync-3.0.9/main.c, line=1516): entered  
rsync error: error starting client-server protocol (code 5) at /usr/src/ports/rsync/rsync-3.0.9-1/src/rsync-3.0.9/main.c  
(1516) [sender=3.0.9]  
[sender] _exit_cleanup(code=5, file=/usr/src/ports/rsync/rsync-3.0.9-1/src/rsync-3.0.9/main.c, line=1516): about to call
 exit(5)

I’m using Cygwin rsync version 3.0.9 on the client and rsync version 3.1.0 on the server.

On the server, rsync is running as root:

root@nas:/mnt/HD/HD_a2# ps aux | grep rsync  
root     10074  0.0  0.3   1996   376 ?        Ss   21:57   0:00 /ffp/bin/rsync --daemon --config=/ffp/etc/rsyncd.conf --log-file=/var/log/rsync.log --ipv4 -vvvv

Why is chdir failing?

root can write to /mnt/HD/HD_a2/rsync:

root@nas:/mnt/HD/HD_a2/rsync# touch /mnt/HD/HD_a2/rsync/touch  
root@nas:/mnt/HD/HD_a2/rsync# ls -la  
total 8  
drwxrwxrwx  2 nobody allaccount 4096 Oct  2 22:21 .  
drwxrwxrwx 23 root   root       4096 Oct  2 19:44 ..    
-rw-r--r--  1 root   root          0 Oct  2 22:21 touch  

and rsync is running as root.

There’s nothing useful in the log on the server:

2014/10/02 22:19:35 [10391] rsyncd version 3.1.0 starting, listening on port 873  
2014/10/02 22:19:41 [10394] connect from UNDETERMINED (192.168.10.37)  

So why is chdir failing? or how can I diagnose the problem further?

UPDATE #1

Regarding this being a duplicate of Configuring anonymous rsync daemon but the solutions pertained to SELinux being the issue. The DNS-320 runs an embedded, slimmed down version of Linux, which does not include SELinux’s getenforce and setenforce commands, so if it is this, as suggested in the comments, how can I rectify it?

As these tools aren’t available, what else could it be?

Hello Community,

I wrote a script one year ago which does a backup from one LUKS-encrypted device to another one. I do backups from /home, /etc, etc.

I also did a cron job about this to automatically save all my data after a period of time. And this really worked all the time. The old data still resides on my second encrypted hard disk.

Now I’m getting an error when I try to backup my /home and /root partition. rsync cannot chdir (cd I guess?) to /home/spiri. But /home/spiri is my home path and this path really exists.

Just the parent directories are getting copied without any file and not the same permissions as the original files (did rsync -a).

[spiri@linux][spiri(x3)@bash]$ sudo systemctl disable --now rsyncd
[sudo] password for spiri: 
Removed /etc/systemd/system/multi-user.target.wants/rsyncd.service.
[spiri@linux][spiri(x3)@bash]$ sudo systemctl enable --now rsyncd
Created symlink /etc/systemd/system/multi-user.target.wants/rsyncd.service → /usr/lib/systemd/system/rsyncd.service.
[spiri@linux][spiri(x3)@bash]$ sudo rsync -av root@localhost::auto::root .
receiving incremental file list
./

sent 27 bytes  received 47 bytes  148.00 bytes/sec
total size is 0  speedup is 0.00
[spiri@linux][spiri(x3)@bash]$ sudo rsync -av root@localhost::auto::home.spiri .
@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1777) [Receiver=3.2.1]
[spiri@linux][spiri(x3)@bash]$ systemctl status rsyncd
● rsyncd.service - fast remote file copy program daemon
     Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled)
     Active: active (running) since Wed 2020-07-08 22:07:34 CEST; 45s ago
       Docs: man:rsync(1)
             man:rsyncd.conf(5)
   Main PID: 38241 (rsync)
      Tasks: 1 (limit: 19023)
     Memory: 1.1M
     CGroup: /system.slice/rsyncd.service
             └─38241 /usr/bin/rsync --daemon --no-detach

Jul 08 22:07:34 at-home systemd[1]: Started fast remote file copy program daemon.
Jul 08 22:07:34 at-home rsyncd[38241]: rsyncd version 3.2.1 starting, listening on port 873
Jul 08 22:07:57 at-home rsyncd[38292]: connect from localhost (127.0.0.1)
Jul 08 22:07:57 at-home rsyncd[38292]: rsync allowed access on module auto::root from localhost (127.0.0.1)
Jul 08 22:07:57 at-home rsyncd[38292]: rsync on auto::root/ from localhost (127.0.0.1)
Jul 08 22:07:57 at-home rsyncd[38292]: building file list
Jul 08 22:07:57 at-home rsyncd[38292]: sent 67 bytes  received 32 bytes  total size 0
Jul 08 22:08:06 at-home rsyncd[38322]: connect from localhost (127.0.0.1)
Jul 08 22:08:06 at-home rsyncd[38322]: rsync allowed access on module auto::home.spiri from localhost (127.0.0.1)
Jul 08 22:08:06 at-home rsyncd[38322]: rsync: [Receiver] chdir /home/spiri failed: No such file or directory (2)
[spiri@linux][spiri(x3)@bash]$ sudo ls -ld root home
drwxrwx--- 3 root root 4096 Jul  8 16:01 home
d--------- 2 root root 4096 Jul  8 15:57 root

I found on the Internet adding «use chroot = yes» would solve the problem but this is not true for me.

I get chdir error for my /home/spiri and an empty directory for /root. Also I am running rsync as root.

Here is my config:

uid = nobody
gid = nobody
use chroot = no
max connections = 4
syslog facility = local5
pid file = /run/rsyncd.pid
address = 127.0.0.1
port = 873
# listen = 1
max connections = 1


[auto::home.spiri]
	path = /home/spiri
	comment = My home directory
	uid = root
	gid = root
	read only = true
	exclude = *
	include = ...


[auto::root]
	path = /root
	comment = Private area
	uid = root
	gid = root
	read only = true
	exclude = *
	include = ...

Last edited by spiri (2020-07-16 13:33:00)

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account


Closed

filipsPL opened this issue

Jul 1, 2020

· 2 comments

Assignees

@WayneD

Comments

@filipsPL

As a follow up for issue #43. After applying changes, I get a new error:

Client (rsync version 3.1.3 protocol version 31):

rsync -av --password-file=pa.txt file.png  rsync://user@host/dir/
@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1675) [sender=3.1.3]

Server (rsync version 3.2.1 protocol version 31):

2020/07/01 09:00:40 [2017875] rsync: [Receiver] chdir /home/localdir failed: No such file or directory (2)

All directories mentioned above exist. When downgrading to rsync 3.1.3 everything works fine.

@WayneD

I imagine that you’re running that under systemd? The default config was tightened up to set ProtectHome=on by default, so you should run something like sudo systemctl edit rsync and specify:

[Service]
ProtectHome=off

… and then sudo systemctl restart rsync.

I think that this restriction is a bit too much of a change, so I’m going to turn it off for 3.2.2.

@WayneD
WayneD

changed the title
@ERROR: chdir failed

@ERROR: chdir failed (daemon failure due to new systemd ProtectHome=on restriction)

Jul 1, 2020

@WayneD

I’ve committed the change to turn this off.

2 participants

@WayneD

@filipsPL

I was trying to get a more complicated module rsyncing, but it seems that I cannot get the most basic example working…

I have a very simple rsyncd.conf file with a single module running under xinetd;

use chroot  = false
strict modes = false
hosts allow = *

[thumbnails]
path = /test
read only = false

The path has been created and has liberal permissions

    # ls -la /test/
    total 16
    drwxrwxrwx  2 root root 4096 Jul 12 21:50 .
    drwxr-xr-x 26 root root 4096 Jul 12 21:50 ..

xinetd has been configured to run rsyncd as the root user (which was the default);

# cat /etc/xinetd.d/rsync   
# default: off
# description: The rsync server is a good addition to an ftp server, as it 
#       allows crc checksumming etc.
service rsync
{
        disable         = no
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}

xinetd has been restarted;

# service xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]

However a simple rsync command to that module fails;

# rsync -va /root/testfolder/ localhost::thumbnails
@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1296) [sender=2.6.8]


Jul 12 21:55:23 opencirrus-i1106 xinetd[10142]: xinetd Version 2.3.14 started with libwrap
 loadavg labeled-networking options compiled in.
Jul 12 21:55:23 opencirrus-i1106 xinetd[10142]: Started working: 1 available service
Jul 12 21:55:27 opencirrus-i1106 xinetd[10142]: START: rsync pid=10147 from=127.0.0.1
Jul 12 21:55:27 opencirrus-i1106 rsyncd[10147]: connect from localhost.localdomain (127.0.
0.1)
Jul 12 21:55:27 opencirrus-i1106 rsyncd[10147]: rsync: chdir /test failed : Permission den
ied (13)
Jul 12 21:55:27 opencirrus-i1106 xinetd[10142]: EXIT: rsync status=255 pid=10147 duration=
0(sec)

I am suspecting that rsync might be dropping permission from root to whatever process actually makes the rsync copy, but whatever it is I can’t immediatly see what as the daemon, nobody and sync users can all cd and write in /test.

If I run rsync from the command line eg;

# rsync --daemon 
# rsync -va /root/testfolder/ localhost::thumbnails

this works fine.

I tried the following modifications to the rsyncd.conf;

# cat /etc/rsyncd.conf 
use chroot  = false
strict modes = false
hosts allow = *

[thumbnails]
path = /test
read only = false 
uid = 501
gid = 501

where 501/501 is the uid/gid of a new user I created and chowned the /test folder to it, but I get the same problem.

Other information

Centos 5.4 x86_64
# rsync -v
rsync  version 2.6.8  protocol version 29

additional info…

# ls -alZ /test                 
drwxr-xr-x  rsync-www rsync-www root:object_r:default_t          .
drwxr-xr-x  root      root      system_u:object_r:root_t         ..
-rw-r--r--  rsync-www rsync-www root:object_r:default_t          frontCover40X60.jpg
-rw-r--r--  rsync-www rsync-www root:object_r:default_t          test
-rw-r--r--  rsync-www rsync-www root:object_r:default_t          test2
drwxr-xr-x  rsync-www rsync-www root:object_r:default_t          testdir
-rw-r--r--  rsync-www rsync-www root:object_r:default_t          test.jpg
drwxr-xr-x  rsync-www rsync-www root:object_r:default_t          tetxdir2
drwxr-xr-x  rsync-www rsync-www root:object_r:default_t          tetxdir3

Понравилась статья? Поделить с друзьями:
  • Rsync error remote command not found
  • Rs9 machinist x99 коды ошибок
  • Rsync error protocol incompatibility code 2
  • Rs 232 framing error
  • Rsync error in socket io code 10