Commit | Line | Data |
---|---|---|
afbebe13 | 1 | --- orig/rsync.c 2004-07-26 16:06:53 |
8075fb75 WD |
2 | +++ rsync.c 2004-07-26 06:27:27 |
3 | @@ -246,6 +246,9 @@ void finish_transfer(char *fname, char * | |
4 | goto do_set_perms; | |
f6c3b300 | 5 | } |
81486408 WD |
6 | |
7 | + /* Change permissions before putting the file into place. */ | |
8075fb75 | 8 | + set_perms(fnametmp, file, NULL, ok_to_set_time ? 0 : PERMS_SKIP_MTIME); |
81486408 WD |
9 | + |
10 | /* move tmp file over real file */ | |
13bed3dd WD |
11 | if (verbose > 2) |
12 | rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname); | |
8075fb75 | 13 | @@ -257,6 +260,10 @@ void finish_transfer(char *fname, char * |
81486408 | 14 | do_unlink(fnametmp); |
8075fb75 | 15 | return; |
81486408 | 16 | } |
8075fb75 WD |
17 | + if (ret == 0) { |
18 | + /* The file was moved into place (not copied), so it's done. */ | |
19 | + return; | |
20 | + } | |
21 | do_set_perms: | |
22 | set_perms(fname, file, NULL, ok_to_set_time ? 0 : PERMS_SKIP_MTIME); | |
23 | } | |
afbebe13 | 24 | --- orig/t_stub.c 2004-07-29 16:08:04 |
13bed3dd | 25 | +++ t_stub.c 2004-07-03 20:17:55 |
81486408 WD |
26 | @@ -26,6 +26,7 @@ |
27 | * functions, so that module test harnesses can run standalone. | |
28 | **/ | |
29 | ||
30 | +int am_root = 0; | |
31 | int modify_window = 0; | |
32 | int module_id = -1; | |
afbebe13 WD |
33 | char *partial_dir; |
34 | --- orig/util.c 2004-07-29 16:08:04 | |
13bed3dd | 35 | +++ util.c 2004-07-03 20:17:55 |
7b675ff5 | 36 | @@ -29,6 +29,7 @@ |
81486408 WD |
37 | |
38 | extern int verbose; | |
7b675ff5 | 39 | extern int dry_run; |
81486408 | 40 | +extern int am_root; |
7b675ff5 WD |
41 | extern int module_id; |
42 | extern int modify_window; | |
afbebe13 WD |
43 | extern char *partial_dir; |
44 | @@ -264,6 +265,8 @@ int copy_file(char *source, char *dest, | |
81486408 WD |
45 | return -1; |
46 | } | |
47 | ||
fbcc0c79 WD |
48 | + if (!am_root && !(mode & S_IWUSR)) |
49 | + mode |= S_IWUSR; | |
81486408 WD |
50 | ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode); |
51 | if (ofd == -1) { | |
fe6407b5 | 52 | rsyserr(FERROR, errno, "open %s", full_fname(dest)); |
afbebe13 | 53 | @@ -362,8 +365,8 @@ int robust_unlink(char *fname) |
81486408 WD |
54 | #endif |
55 | } | |
56 | ||
57 | -/* Returns 0 on success, -1 on most errors, and -2 if we got an error | |
58 | - * trying to copy the file across file systems. */ | |
59 | +/* Returns 0 on successful rename, 1 if we successfully copied the file | |
60 | + * across filesystems, -2 if copy_file() failed, and -1 on other errors. */ | |
61 | int robust_rename(char *from, char *to, int mode) | |
62 | { | |
63 | int tries = 4; | |
afbebe13 | 64 | @@ -380,10 +383,12 @@ int robust_rename(char *from, char *to, |
81486408 WD |
65 | break; |
66 | #endif | |
67 | case EXDEV: | |
fbcc0c79 WD |
68 | + if (!am_root && !(mode & S_IRUSR)) |
69 | + do_chmod(from, (mode & CHMOD_BITS) | S_IRUSR); | |
81486408 WD |
70 | if (copy_file(from, to, mode) != 0) |
71 | return -2; | |
72 | do_unlink(from); | |
73 | - return 0; | |
74 | + return 1; | |
75 | default: | |
76 | return -1; | |
77 | } |