X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/8458724d2558659cfb5e53443759cac5419b13bf..972a3619c4ea253671e2fe0897f99af897782e26:/rsync.c diff --git a/rsync.c b/rsync.c index 02dd8373..87a8056b 100644 --- a/rsync.c +++ b/rsync.c @@ -200,14 +200,19 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st, } #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 @@ -260,7 +265,7 @@ void finish_transfer(char *fname, char *fnametmp, struct file_struct *file) 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 {