summaryrefslogtreecommitdiff
path: root/receiver.c
diff options
context:
space:
mode:
authorAchim Leitner <git@fjl.de>2021-10-17 22:00:24 +0200
committerGitHub <noreply@github.com>2021-10-17 13:00:24 -0700
commit84498104bfe2a4662221992951e71d2a2f5ceffc (patch)
tree59e4082ada8eec3803d530c6dd43249ebcc6bd04 /receiver.c
parent378a0a634fa7dc71e2646b8eb88b46853fada463 (diff)
downloadrsync-84498104bfe2a4662221992951e71d2a2f5ceffc.tar.gz
Linux: Handle protected_regular in inplace writes (#241)
The Linux fs.protected_regular sysctl setting could cause rsync to fail to write a file in-place with the O_CREAT flag set, so the code now tries an open without O_CREAT when it might help to avoid an EACCES error. A testsuite script is included (and slightly improved by Wayne to ensure that it outputs a SKIP when fs.protected_regular is turned off).
Diffstat (limited to 'receiver.c')
-rw-r--r--receiver.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/receiver.c b/receiver.c
index 091fcd6f..2cd84351 100644
--- a/receiver.c
+++ b/receiver.c
@@ -835,6 +835,12 @@ int recv_files(int f_in, int f_out, char *local_name)
if (inplace || one_inplace) {
fnametmp = one_inplace ? partialptr : fname;
fd2 = do_open(fnametmp, O_WRONLY|O_CREAT, 0600);
+#ifdef linux
+ if (fd2 == -1 && errno == EACCES) {
+ /* Maybe the error was due to protected_regular setting? */
+ fd2 = do_open(fname, O_WRONLY, 0600);
+ }
+#endif
if (fd2 == -1) {
rsyserr(FERROR_XFER, errno, "open %s failed",
full_fname(fnametmp));