link_dest checks perms despite no -p -o or -g

jw schultz jw at pegasys.ws
Tue Apr 8 07:57:18 EST 2003


Already in cvs.

On Mon, Apr 07, 2003 at 02:54:03PM -0700, Kyle Jones wrote:
> When using --link-dest, this block of code in skip_file causes
> new copies of files to be created if source and destination file
> permissions differ, even if -p -o and -g haven't been specified.
> 
> 	if (link_dest) {
> 		if((st->st_mode & ~_S_IFMT) !=  (file->mode & ~_S_IFMT)) {
> 			return 0;
> 		}
> 		if (st->st_uid != file->uid || st->st_gid != file->gid) {
> 			return 0;
> 		}
> 	}
> 
> I think the code should be this instead.
> 
> 	if (link_dest) {
> 		if(preserve_perms &&
> 		   ((st->st_mode & ~_S_IFMT) !=  (file->mode & ~_S_IFMT))) {
> 			return 0;
> 		}
> 		if ((preserve_uid && (st->st_uid != file->uid)) ||
> 		    (preserve_gid && (st->st_gid != file->gid))) {
> 			return 0;
> 		}
> 	}
> 
> Tested lightly here, seems to do the right thing.  Without this change
> you pretty much have to be root to use --link-dest.  Otherwise if you
> can't sync owner/group/perms for some reason (not file owner, chgrp
> fails on remote host, etc.), fresh copies will be created each rsync,
> defeating the purpose of using --link-dest.
> -- 
> To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
> Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html
> 

-- 
________________________________________________________________
	J.W. Schultz            Pegasystems Technologies
	email address:		jw at pegasys.ws

		Remember Cernan and Schmitt


More information about the rsync mailing list