Commit 72914a60 authored by Andrew Tridgell's avatar Andrew Tridgell

make rsync behave more like GNU cp with regard to file permissions

when -p (preserve permissions) isn't set.

It works by taking the sending file permissions and masking them with
the umask to create the destination file permissions. (There is really
no "correct" way of doing this but at least we now behave like GNU cp
which fits the principle of least surprise.)

also fixed a race condition in copy_file()
parent 4b957c22
......@@ -285,6 +285,13 @@ static void receive_file_entry(struct file_struct **fptr,
last_uid = file->uid;
last_gid = file->gid;
last_time = file->modtime;
if (!preserve_perms) {
extern int orig_umask;
/* set an appropriate set of permissions based on original
permissions and umask. This emulates what GNU cp does */
file->mode &= ~orig_umask;
}
}
......
......@@ -855,7 +855,7 @@ static void finish_transfer(char *fname, char *fnametmp, struct file_struct *fil
if (errno == EXDEV) {
/* rename failed on cross-filesystem link.
Copy the file instead. */
if (copy_file(fnametmp,fname, file->mode)) {
if (copy_file(fnametmp,fname, file->mode & ACCESSPERMS)) {
rprintf(FERROR,"copy %s -> %s : %s\n",
fnametmp,fname,strerror(errno));
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment