History

solved the problem of not using the right permissions when preserve_perms is off.

Andrew Tridgell committed 27 years ago

Commit 4df9f361 parent 5c9730a2 files · +18 −0Browse files

Unified · Split

2 files
  1. generator.c +10 −0
  2. receiver.c +8 −0
generator.c+10−0
@@ -177,6 +177,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out) · 176 unmodified lines
177177 char fnamecmpbuf[MAXPATHLEN];
178178 extern char *compare_dest;
179179 extern int list_only;
180+ extern int preserve_perms;
180181
181182 if (list_only) return;
182183
@@ -185,6 +186,15 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out) · 2 unmodified lines
185186
186187 statret = link_stat(fname,&st);
187188
189+ if (statret == 0 &&
190+ !preserve_perms &&
191+ (S_ISDIR(st.st_mode) == S_ISDIR(file->mode))) {
192+ /* if the file exists already and we aren't perserving
193+ presmissions then act as though the remote end sent
194+ us the file permissions we already have */
195+ file->mode = st.st_mode;
196+ }
197+
188198 if (S_ISDIR(file->mode)) {
189199 if (dry_run) return;
190200 if (statret == 0 && !S_ISDIR(st.st_mode)) {
receiver.c+8−0
@@ -303,6 +303,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen) · 302 unmodified lines
303303 int phase=0;
304304 int recv_ok;
305305 extern struct stats stats;
306+ extern int preserve_perms;
306307 struct stats initial_stats;
307308
308309 if (verbose > 2) {
@@ -383,6 +384,13 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen) · 74 unmodified lines
383384 continue;
384385 }
385386
387+ if (fd1 != -1 && !preserve_perms) {
388+ /* if the file exists already and we aren't perserving
389+ presmissions then act as though the remote end sent
390+ us the file permissions we already have */
391+ file->mode = st.st_mode;
392+ }
393+
386394 if (fd1 != -1 && st.st_size > 0) {
387395 buf = map_file(fd1,st.st_size);
388396 if (verbose > 2)