Handle the --chmod option as either the sender or the receiver so

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).
This commit is contained in:
Wayne Davison
2006-01-21 08:03:18 +00:00
parent ba30fb5c3c
commit 8bbe41b53b

13
flist.c
View File

@@ -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);