--link-dest uid/gid checking bug?
Chris Darroch
chrisd at pearsoncmg.com
Sat Mar 22 02:46:27 EST 2003
Hi --
J. W. Schultz wrote:
>> 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.
OK, thanks -- here's the patch I'm using now for my own
installation.
If there's no desire to put it (or a better version of it)
into CVS, then I'd suggest changing the man page so that the
behaviour of rsync with --list-dest but without --owner, --group,
and --perms is documented. Otherwise it's somewhat counter-intuitive:
hard links are created, then immediately deleted, and the files
transferred anyway.
Thanks,
Chris.
diff -u generator.c.orig generator.c
====================================
--- generator.c.orig 2003-03-19 15:07:29.592476000 -0500
+++ generator.c 2003-03-20 10:26:04.050060000 -0500
@@ -52,10 +52,14 @@
return 0;
}
if (link_dest) {
- if((st->st_mode & ~_S_IFMT) != (file->mode & ~_S_IFMT)) {
+ extern int preserve_perms;
+ extern int preserve_uid;
+ extern int preserve_gid;
+
+ if(preserve_perms && ((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;
}
}
====================================
More information about the rsync
mailing list