A more readable version of the previous diff.
The first change moves the setfile() call out of
the 'if' to avoid the case of the pflag being active
and setfile() returning 0 witch makes the retainbits
block executed, it might not be desirable after the
chmod() in setfile().
Thanks for your time.
-Jesus
------------------------------------------------------
--- utils.c.orig Wed Jun 15 08:06:09 2011
+++ utils.c Wed Jun 15 08:55:13 2011
@@ -170,8 +170,10 @@
return (1);
}
- if (pflag && setfile(fs, to_fd))
- rval = 1;
+ if (pflag) {
+ if (setfile(fs, to_fd))
+ rval = 1;
+ }
/*
* If the source was setuid or setgid, lose the bits unless the
* copy is owned by the same user and group.
@@ -183,7 +185,8 @@
warn("%s", to.p_path);
rval = 1;
} else if (fs->st_gid == to_stat.st_gid &&
- fchmod(to_fd, fs->st_mode & RETAINBITS & ~myumask)) {
+ fchmod(to_fd, (((S_ISUID | S_ISGID) & fs->st_mode)
+ | to_stat.st_mode) & RETAINBITS)) {
warn("%s", to.p_path);
rval = 1;
}