axkibe/lsyncd — Issue #94: User and Group ownership not preserved
Author: axkibe
Created: 2011-11-16 15:12:33+00:00
State: open

Originally filed by stefan.m...@gmail.com on 2011-11-14T09:02:23

What steps will reproduce the problem?
1. Use lsyncd with configuration stated below.
2. Run initial synch when target is empty, or subsequent ones that add new files to the target.
3. Compare permissions of newly created files on target with source.

When I use this configuration I would expect lsyncd to preserve user and group ids.

sync {
default.rsync,
source="/home/user/data/mail",
target="server02:/home/user/data/mail",
rsyncOpts = "-a",
}

Because the rsync manual states that -a includes the arguments -u, -g and -o. Which preserve user, group and owner respectively.

I can also verify that both systems are identical, the user owning the files in the source directory is postfix and group is postfix.

server01# grep postfix /etc/{passwd,group}
/etc/passwd:postfix:x:105:108::/var/spool/postfix:/bin/false
/etc/group:postfix:x:108:

server02# grep postfix /etc/{passwd,group}
/etc/passwd:postfix:x:105:108::/var/spool/postfix:/bin/false
/etc/group:postfix:x:108:

I have 3.0.7 protocol version 30 installed of rsync and if I do the manual command below here the files are created on server02 with the correct permissions. Indicating the issue is with lsyncd or my configuration of lsyncd.

rsync -a /home/user/data/mail server02:/home/user/data/

I can also add -e ssh without problems.

I am using lsyncd 2.0.4-1 from Debian 6 Squeeze packages. Both systems are identical Debian 6.0.2 installed simultaneously for failover purposes.

My test case uses the configuration of /etc/courier, some files are owned by daemon here but this will not be preserved by lsyncd.

Even in this case I have made sure daemon has the same uid and gid on both machines.

settings = {
logfile = "/var/log/lsyncd.log",
statusfile = "/var/run/lsyncd.status",
nodaemon = false,
}

sync {
default.rsync,
source="/etc/courier",
target="server02:/etc/courier",
rsyncOpts="-a",
}

I make sure to delete /etc/courier on server02 first, then restart lsyncd on server01. This causes the files to be copied over but on server02 they're owned by root:root and on server01 they're owned by daemon:daemon.

server02# ls -la /etc/courier/
total 40
drwxr-xr-x 3 root root 4096 Oct 12 12:27 .
drwxr-xr-x 78 root root 4096 Nov 14 09:32 ..
-rw-r----- 1 root root 3656 Oct 12 13:48 authdaemonrc
-rw-r----- 1 root root 8136 Oct 12 13:32 authpgsqlrc
-rw-r--r-- 1 root root 13913 Oct 12 13:34 imapd
drwxr-xr-x 2 root root 4096 Oct 12 12:27 shared

server01# ls -la /etc/courier/
total 40
drwxr-xr-x 3 root root 4096 Oct 12 12:27 .
drwxr-xr-x 85 root root 4096 Nov 10 14:29 ..
-rw-rw---- 1 daemon daemon 3656 Oct 12 13:48 authdaemonrc
-rw-rw---- 1 daemon daemon 8136 Oct 12 13:32 authpgsqlrc
-rw-r--r-- 1 root root 13913 Oct 12 13:34 imapd
drwxr-xr-x 2 daemon daemon 4096 Oct 12 12:27 shared

However, if I again delete the /etc/courier directory on server02, and run rsync -a /etc/courier server02:/etc/ I get the correct permissions.