Handle the --chmod option as either the sender or the receiver so
authorWayne Davison <wayned@samba.org>
Sat, 21 Jan 2006 08:03:18 +0000 (08:03 +0000)
committerWayne Davison <wayned@samba.org>
Sat, 21 Jan 2006 08:03:18 +0000 (08:03 +0000)
that only the client needs to know about --chmod (but if an older
version sends the option to the server, we'll still handle it).

flist.c

diff --git a/flist.c b/flist.c
index 9654bd7..8f4e182 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -569,6 +569,9 @@ static struct file_struct *receive_file_entry(struct file_list *flist,
        if (!(flags & XMIT_SAME_MODE))
                mode = from_wire_mode(read_int(f));
 
+       if (chmod_modes && (S_ISREG(mode) || S_ISDIR(mode)))
+               mode = tweak_mode(mode, chmod_modes);
+
        if (preserve_uid && !(flags & XMIT_SAME_UID))
                uid = (uid_t)read_int(f);
        if (preserve_gid && !(flags & XMIT_SAME_GID))
@@ -870,10 +873,7 @@ struct file_struct *make_file(char *fname, struct file_list *flist,
        file->flags = flags;
        file->modtime = st.st_mtime;
        file->length = st.st_size;
-       if (chmod_modes && am_sender && (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)))
-               file->mode = tweak_mode(st.st_mode, chmod_modes);
-       else
-               file->mode = st.st_mode;
+       file->mode = st.st_mode;
        file->uid = st.st_uid;
        file->gid = st.st_gid;
 
@@ -936,7 +936,7 @@ struct file_struct *make_file(char *fname, struct file_list *flist,
        if (keep_dirlinks && linkname_len && flist) {
                STRUCT_STAT st2;
                int save_mode = file->mode;
-               file->mode = S_IFDIR; /* find a directory w/our name */
+               file->mode = S_IFDIR; /* Find a directory with our name. */
                if (flist_find(the_file_list, file) >= 0
                    && do_stat(thisname, &st2) == 0 && S_ISDIR(st2.st_mode)) {
                        file->modtime = st2.st_mtime;
@@ -966,6 +966,9 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
        if (!file)
                return NULL;
 
+       if (chmod_modes && (S_ISREG(file->mode) || S_ISDIR(file->mode)))
+               file->mode = tweak_mode(file->mode, chmod_modes);
+
        maybe_emit_filelist_progress(flist->count + flist_count_offset);
 
        flist_expand(flist);