The change a couple days ago to create files initially without group and
[rsync/rsync.git] / rsync.c
diff --git a/rsync.c b/rsync.c
index 02dd837..87a8056 100644 (file)
--- 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 {