}
#ifdef HAVE_CHMOD
- if (preserve_perms && !S_ISLNK(st->st_mode) &&
- (st->st_mode != file->mode ||
- (updated && (file->mode & ~INITPERMMASK)))) {
- updated = 1;
- if (do_chmod(fname,file->mode) != 0) {
- rprintf(FERROR,"failed to set permissions on %s : %s\n",
- fname,strerror(errno));
- return 0;
+ if (!S_ISLNK(st->st_mode)) {
+ int file_mode;
+ if (preserve_perms)
+ file_mode = file->mode;
+ else
+ file_mode = file->mode & ACCESSPERMS;
+ if (st->st_mode != file->mode) {
+ updated = 1;
+ if (do_chmod(fname,file_mode) != 0) {
+ rprintf(FERROR,"failed to set permissions on %s : %s\n",
+ fname,strerror(errno));
+ return 0;
+ }
}
}
#endif
if (errno == EXDEV) {
/* rename failed on cross-filesystem link.
Copy the file instead. */
- if (copy_file(fnametmp,fname, file->mode & INITPERMMASK)) {
+ if (copy_file(fnametmp,fname, file->mode & INITACCESSPERMS)) {
rprintf(FERROR,"copy %s -> %s : %s\n",
fnametmp,fname,strerror(errno));
} else {