From a9d6e6fcacf363b25023aeec3c8d706714ebebcd Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Tue, 31 Jan 2006 02:30:09 +0000 Subject: [PATCH] When permissions aren't being preserved, set them via the new dest_mode() function. --- generator.c | 13 ++++++------- receiver.c | 10 +++++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/generator.c b/generator.c index 44a097d4..4db5cbac 100644 --- a/generator.c +++ b/generator.c @@ -855,13 +855,12 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, return; } - if (statret == 0 && !preserve_perms - && S_ISDIR(st.st_mode) == S_ISDIR(file->mode)) { - /* if the file exists already and we aren't perserving - * permissions then act as though the remote end sent - * us the file permissions we already have */ - file->mode = (file->mode & ~CHMOD_BITS) - | (st.st_mode & CHMOD_BITS); + /* If we're not preserving permissions, change the file-list's + * mode based on the local permissions and some heuristics. */ + if (!preserve_perms) { + int exists = statret == 0 + && S_ISDIR(st.st_mode) == S_ISDIR(file->mode); + file->mode = dest_mode(file->mode, st.st_mode, exists); } if (S_ISDIR(file->mode)) { diff --git a/receiver.c b/receiver.c index 30cdc36c..918dad86 100644 --- a/receiver.c +++ b/receiver.c @@ -603,11 +603,11 @@ int recv_files(int f_in, struct file_list *flist, char *local_name) fd1 = -1; } - if (fd1 != -1 && !preserve_perms) { - /* if the file exists already and we aren't preserving - * permissions then act as though the remote end sent - * us the file permissions we already have */ - file->mode = st.st_mode; + /* If we're not preserving permissions, change the file-list's + * mode based on the local permissions and some heuristics. */ + if (!preserve_perms) { + int exists = fd1 != -1; + file->mode = dest_mode(file->mode, st.st_mode, exists); } /* We now check to see if we are writing file "inplace" */ -- 2.34.1