trouble with chmod on certain symlinks

Ben Bond-Lamberty bpbond at
Fri Dec 31 01:14:54 GMT 2004

I and a few others have seen similar problems.  It happens (as I understand)
because Darwin (the BSD underlying Mac OS X) follows symlinks with chown
attempts--try chown'ing a symlink from the command line to see this--which
is...unintuitive.  So when given the -o or -g (or -a) options, rsync can
unintentionally end up following links and resetting the permissions on the
target, not the symlink.

Jonathan Paisley at Glasgow (UK) Computing Science has used the patch below
in the rsyncX.c source (but should be same for rsync?), preventing it from
following symlinks in this situation; I have not tried this myself.  Hope
this helps.


diff -u -r1.1.1.6 rsync.c
--- rsync.c     3 Jan 2004 11:22:00 -0000
+++ rsync.c     21 Dec 2004 12:04:56 -0000
@@ -260,7 +260,7 @@
                     change to groups that the user is a member of */
                 change_gid = is_in_group(file->gid);
-       if (change_uid || change_gid) {
+       if (!S_ISLNK(st->st_mode) && (change_uid || change_gid)) {
                 if (do_lchown(fname,
                               change_gid?file->gid:st->st_gid) != 0) {

On 12/28/04 6:00 AM, btb <btb at> wrote:

> i am using rsync via ssh to maintain a copy of a few directories on a
> remote server, and am getting an error when rsync tries to chmod a
> certain file following it's transfer.  there are a couple of cases in
> which this occurring - below is one example.

More information about the rsync mailing list