Project

General

Profile

Submit #2988 ยป submit_2988.diff

asomers, 03/24/2017 03:48 PM

View differences:

bin/cpdup/cpdup.c
static int
FlagsMatch(struct stat *st1, struct stat *st2)
{
if (DstRootPrivs)
return (st1->st_flags == st2->st_flags);
else
/* Only consider the user-settable flags. */
return (((st1->st_flags ^ st2->st_flags) & UF_SETTABLE) == 0);
/*
* Ignore UF_ARCHIVE. It gets set automatically by the filesystem, for
* filesystems that support it. If the destination filesystem supports it, but
* it's cleared on the source file, then multiple invocations of cpdup would
* all try to copy the file because the flags wouldn't match.
*
* When unpriveleged, ignore flags we can't set
*/
u_long ignored = DstRootPrivs ? 0 : SF_SETTABLE;
#ifdef UF_ARCHIVE
ignored |= UF_ARCHIVE;
#endif
return (((st1->st_flags ^ st2->st_flags) & ~ignored) == 0);
}
#endif
    (1-1/1)