Hello,
rsync is unable to overwrite read-only destination files with the
--inplace option. I think this is expected behavior but not convenient
for our case. I wrote a small patch that in case of an permission denied
error, adds the owner write bit to the permissions and tries to open the
destination file again for write again.

It's not very elegant but it solved our problem. I attached the patch in
case it's useful for someone.

Cheers,
Bram

-- 
Institute of Astronomy
Universtity of Leuven



diff --git a/syscall.c b/syscall.c
index dae92bc..239b0af 100644
--- a/syscall.c
+++ b/syscall.c
@@ -202,7 +202,16 @@ int do_open(const char *pathname, int flags, mode_t mode)
 		RETURN_ERROR_IF_RO_OR_LO;
 	}
 
-	return open(pathname, flags | O_BINARY, mode);
+	int fd = open(pathname, flags | O_BINARY, mode);
+
+	if (fd == -1 && flags == (O_WRONLY|O_CREAT) && errno == EPERM) {
+		STRUCT_STAT st;
+		if (do_lstat(pathname, &st) == 0) {
+                	chmod(pathname, (st.st_mode & 0x0777) | S_IWUSR); //add write bit for owner
+			fd = open(pathname, flags | O_BINARY, mode);
+		}
+	}
+	return fd;
 }
 
 #ifdef HAVE_CHMOD
-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to