--link-dest uid/gid checking bug?

jw schultz jw at pegasys.ws
Thu Mar 20 12:32:06 EST 2003


On Wed, Mar 19, 2003 at 04:38:43PM -0500, Chris Darroch wrote:
> Hi --
> 
>    I was very keen to download rsync and give it a whirl with the
> new --link-dest feature.  However, I was terribly puzzled when I
> couldn't seem to get it working, even though --compare-dest with
> the same argument would work.  It seemed like new files would
> be transferred even though files existed in the compare-dest/link-dest
> location; compare-dest would detect them but link-dest would make
> new files anyway.
> 
>    I tracked down my confusion to the new portion of skip_file()
> in generator.c.  Because I wasn't supplying the --owner or --group
> options, the preserve_uid and preserve_gid flags were not set,
> and the source file's file->uid and file->gid values were just 0.
> But skip_file() was checking them against the destination file's
> st->st_uid and st->st_gid, and reporting the difference.
> 
>    Here's my stab at a patch -- I only just looked at the rsync
> code today, so I might very well be missing something.

Looks pretty good.

However it once you start on this path it would be best to
also check preserve_perms in the preceeding mode test.

> 
> Thanks,
> 
> Chris.
> 
> 
> diff -u generator.c.orig generator.c
> ====================================
> --- generator.c.orig	2003-03-19 15:07:29.592476000 -0500
> +++ generator.c	2003-03-19 16:12:24.994685000 -0500
> @@ -27,6 +27,8 @@
>  extern int dry_run;
>  extern int relative_paths;
>  extern int preserve_links;
> +extern int preserve_uid;
> +extern int preserve_gid;
>  extern int am_root;
>  extern int preserve_devices;
>  extern int preserve_hard_links;
> @@ -55,7 +57,8 @@
>  		if((st->st_mode & ~_S_IFMT) !=  (file->mode & ~_S_IFMT)) {
>  			return 0;
>  		}
> -		if (st->st_uid != file->uid || st->st_gid != file->gid) {
> +		if ((preserve_uid && st->st_uid != file->uid) ||
> +			(preserve_gid && st->st_gid != file->gid)) {
>  			return 0;
>  		}
>  	}
> ====================================
> 
> -- 
> GPG Key ID: 366A375B
> GPG Key Fingerprint: 485E 5041 17E1 E2BB C263  E4DE C8E3 FA36 366A 375B
> 
> 
> -- 
> 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