cp -p could report success even if a file copy failed. This was due to

the cumulative exit status being overwritten when directory permissions
were being set.  This was particularly bad when called from mv(1) to
perform a cross-device move as the original files were deleted even if
the copy failed.

Reported by:    Slaven Rezic <slaven.rezic@berlin.de>
Patch by:       bde
PR:             42789
This commit is contained in:
Stephen McKay 2002-09-22 11:15:56 +00:00
parent a0c6726472
commit eedc99e7b5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=103801

View File

@ -361,9 +361,10 @@ copy(char *argv[], enum op type, int fts_options)
* honour setuid, setgid and sticky bits, but we
* normally want to preserve them on directories.
*/
if (pflag)
rval = setfile(curr->fts_statp, 0);
else {
if (pflag) {
if (setfile(curr->fts_statp, 0))
rval = 1;
} else {
mode = curr->fts_statp->st_mode;
if ((mode & (S_ISUID | S_ISGID | S_ISTXT)) ||
((mode | S_IRWXU) & mask) != (mode & mask))